Ooops
January 15, 2021, 05:30:23 PM

Author Topic: [bmx] fmc.Tweaks by Fabian. [ 1+ years ago ]  (Read 572 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] fmc.Tweaks by Fabian. [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : fmc.Tweaks
Author : Fabian.
Posted : 1+ years ago

Description : Since 2006-11-06 my modules stored in the code archives are out of synchronization. To have the latest version you need to use the bmk/syncmods utility or the MaxIDE.

You need to add "webspace100.we.funpic.de/root/mod" as a new line to "cfg/modservers.cfg" in your BlitzMax installation directory.

You can't synchronize with the default BlitzMax 1.22 IDE. If you don't have another IDE, you need to download a <a href="http://webspace100.we.funpic.de/root/programs/MaxIDE.exe" target="_blank">tweaked MaxIDE[/url]. You need to specify "fmc" as additional module scope.

Alternative you can synchronize with the bmk tool: bmk syncmods fmc

For a better description see my <a href="../Community/posts37e4.html?topic=69294" target="_blank">thread[/url] in the programming forum introducing these modules.

Needed modules:
<a href="codearcsb7bf.html?code=1786" >fmc.Development[/url]


Code :
Code: BlitzMax
  1. Strict
  2. Module fmc.Tweak
  3.  
  4. ModuleInfo "Version: 0.07"
  5. ModuleInfo "Modserver: Fabian"
  6.  
  7. Import fmc.Development
  8. Import brl.win32maxgui
  9. Import brl.stream
  10. Import brl.socket
  11.  
  12. Private
  13.  
  14. Global __SetHotKeyEvent:TFunctionHook = TFunctionHook.Create ( SetHotKeyEvent , _SetHotKeyEvent )
  15. Global __bbSetPointer:TFunctionHook = TFunctionHook.Create ( bbSetPointer , _bbSetPointer )
  16. Global __CasedFileName:TFunctionHook = TFunctionHook.Create ( CasedFileName , _CasedFileName )
  17. Global __OpenStream:TFunctionHook '= TFunctionHook.Create ( OpenStream , _OpenStream )
  18. Global __bbObjectNew:TFunctionHook '= TFunctionHook.Create ( bbObjectNew , _bbObjectNew )
  19. Global __ActivateWindow:TFunctionHook = TFunctionHook.Create ( ActivateWindow , _ActivateWindow )
  20. Global __UpdateLocalName:TFunctionHook = TFunctionHook.Create ( UpdateLocalName , _UpdateLocalName )
  21. Global __UpdateRemoteName:TFunctionHook = TFunctionHook.Create ( UpdateRemoteName , _UpdateRemoteName )
  22. Global __HostIp:TFunctionHook = TFunctionHook.Create ( HostIp , _HostIp )
  23. Global __OpenURL:TFunctionHook = TFunctionHook.Create ( OpenURL , _OpenURL )
  24.  
  25. Function _SetHotKeyEvent:THotKey( key,mods,event:TEvent=Null,owner=0 )
  26.         If Not event event=CreateEvent( EVENT_HOTKEYHIT,Null,key,mods )
  27.         Local t:THotKey=hotKeys
  28.         While t
  29.                 If t.key=key And t.mods=mods And t.owner=owner Exit
  30.                 t=t.succ
  31.         Wend
  32.         If Not t
  33.                 t=New THotKey
  34.                 t.key=key
  35.                 t.mods=mods
  36.                 t.owner=owner
  37.                 t.succ=hotKeys
  38.                 hotKeys=t
  39.         EndIf
  40.         t.event=event
  41.         Return t
  42. EndFunction
  43.  
  44. Function _bbSetPointer ( h ) NoDebug
  45.   If h<1 Or h>14
  46.     bbSetCursor 0
  47.     Local Point:Long
  48.     GetCursorPos Varptr Point
  49.     SetCursorPos ( ( Int Ptr Varptr Point ) [ 0 ] , ( Int Ptr Varptr Point ) [ 1 ] )
  50.   Else
  51.     __bbSetPointer.Disable
  52.     bbSetPointer h
  53.     __bbSetPointer.Enable
  54.   EndIf
  55. EndFunction
  56.  
  57. Function _CasedFileName$ ( path$ )
  58.         Local drive$
  59.         If Len path >= 2 And path [ 1 ] = Asc ":"
  60.                 drive = path [.. 2 ].ToUpper ( )
  61.                 path = path [ 2 ..]
  62.         EndIf
  63.         Local folder$ = "." , length = Len path , start
  64.         For Local i = 0 To length
  65.                 If i = length Or path [ i ] = Asc "/" Or path [ i ] = Asc ""
  66.                         If i = start
  67.                                 folder = "/"
  68.                         Else
  69.                                 Local dir = opendir_ ( drive + folder )
  70.                                 If Not dir
  71.                                         Return
  72.                                 EndIf
  73.                                 Local name$ = path [ start .. i ] , file$
  74.                                 Repeat
  75.                                         file = readdir_ ( dir )
  76.                                         If Not file
  77.                                                 closedir_ dir
  78.                                                 Return
  79.                                         EndIf
  80.                                         If file.ToLower ( ) = name.ToLower ( )
  81.                                                 Exit
  82.                                         EndIf
  83.                                 Forever
  84.                                 closedir_ dir
  85.                                 folder = path [.. start ] + file
  86.                                 path = folder + path [ i ..]
  87.                         EndIf
  88.                         start = i + 1
  89.                 EndIf
  90.         Next
  91.         Return drive + path
  92. EndFunction
  93.  
  94. Global stream_factories:TStreamFactory
  95.  
  96. Function _OpenStream:TStream( url:Object,readable=True,writeable=True )
  97.  
  98.         Local stream:TStream=TStream( url )
  99.         If stream
  100.                 Return TStreamStream.Create( stream )
  101.         EndIf
  102.  
  103.         Local str$=String( url ),proto$,path$
  104.         If str
  105.                 Local i=str.Find( "::",0 )
  106.                 If i=-1
  107.                         Local r:TStream=TCStream.OpenFile( str,readable,writeable )
  108.                         If r Return r
  109.                 Else
  110.                         proto$=str[..i].ToLower()
  111.                         path$=str[i+2..]
  112.                 EndIf
  113.         EndIf
  114.  
  115.         Local factory:TStreamFactory=stream_factories
  116.        
  117.         While factory
  118.                 Local stream:TStream=factory.CreateStream( url,proto,path,readable,writeable )
  119.                 If stream Return stream
  120.                 factory=factory._succ
  121.         Wend
  122. EndFunction
  123.  
  124. Function _bbObjectNew:Object ( t ) NoDebug
  125.   __bbObjectNew.Disable
  126.   Local obj:Object = bbObjectNew ( t )
  127.   __bbObjectNew.Enable
  128.   Local f:TStreamFactory = TStreamFactory ( obj )
  129.   If f
  130.     stream_factories = f
  131.   EndIf
  132.   Return obj
  133. EndFunction
  134.  
  135. Function _ActivateWindow ( window:TGadget )
  136.   SetForegroundWindow QueryGadget ( window , QUERY_HWND )
  137. EndFunction
  138.  
  139. Function _UpdateLocalName ( socket:TSocket )
  140.         Local addr:Byte Ptr=MemAlloc(16),size=16
  141.         If getsockname_( socket._socket,addr,size )<0
  142.                 socket._localIp=0
  143.                 socket._localPort=0
  144.                 MemFree addr
  145.         EndIf
  146.         socket._localIp=addr[4] Shl 24 | addr[5] Shl 16 | addr[6] Shl 8 | addr[7]
  147.         socket._localPort=addr[2] Shl 8 | addr[3]
  148.         MemFree addr
  149. EndFunction
  150.  
  151. Function _UpdateRemoteName ( socket:TSocket )
  152.         Local addr:Byte Ptr=MemAlloc(16),size=16
  153.         If getpeername_( socket._socket,addr,size )<0
  154.                 socket._remoteIp=0
  155.                 socket._remotePort=0
  156.                 MemFree addr
  157.                 Return
  158.         EndIf
  159.         socket._remoteIp=addr[4] Shl 24 | addr[5] Shl 16 | addr[6] Shl 8 | addr[7]
  160.         socket._remotePort=addr[2] Shl 8 | addr[3]
  161.         MemFree addr
  162. EndFunction
  163.  
  164. Function _HostIp ( HostName$ , index = 0 )
  165.         If index<0 Return
  166.         Local addr_type,addr_len
  167.         Local addrs:Byte Ptr Ptr=gethostbyname_( HostName,addr_type,addr_len )
  168.         If addrs=Null Or addr_type<>AF_INET_ Or addr_len<>4 Return
  169.         Local n
  170.         While addrs[n]
  171.                 n:+1
  172.         Wend
  173.         Local ips Ptr=Int Ptr MemAlloc(n*4)
  174.         For Local i=0 Until n
  175.                 Local p:Byte Ptr=addrs[i]
  176.                 ips[i]=p[0] Shl 24 | p[1] Shl 16 | p[2] Shl 8 | p[3]
  177.         Next
  178.         Local addr
  179.         If index<n addr=ips[index]
  180.         MemFree ips
  181.         Return addr
  182. EndFunction
  183.  
  184. Function _OpenURL( url$ )
  185.         Return Driver.OpenURL( url )
  186. EndFunction
  187.  
  188. Extern
  189.   Function bbSetPointer ( h )
  190.   Function bbSetCursor ( cursor ) = "_Z11bbSetCursorP7HICON__"
  191.   Function bbObjectNew:Object ( t )
  192.   Function UpdateLocalName ( socket:TSocket ) = "_brl_socket_TSocket_UpdateLocalName"
  193.   Function UpdateRemoteName ( socket:TSocket ) = "_brl_socket_TSocket_UpdateRemoteName"
  194. EndExtern
  195.  
  196. Extern "Win32"
  197.   Function SetForegroundWindow ( Win )
  198.   Function GetCursorPos ( Point:Byte Ptr )
  199.   Function SetCursorPos ( X , Y )
  200. EndExtern


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal