Advertisement
p3king

[RMVXA] Script Editor Tools

Mar 2nd, 2013
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Script Editor Script :)
  2. ;by p3king
  3.  
  4. ;You can use the following hotkeys:
  5. ;- ALT + 1      >  Restore the default window size
  6. ;- ALT + 2      >  Change window size to settings below
  7. ;- ALT + 3      >  Change window size to something else defined in the script
  8.  
  9. ;- CTRL + S     >  Trigger "Apply" button to save
  10. ;- F12          >  Leave script editor, save and start game
  11.  
  12. ;Automatically resize the script window each time you open it with F11
  13. AutoResize = 1
  14.  
  15. ;Script window resizes to this size when pressing ALT + 2 or AutoResize is enabled
  16. WindowWidth = 1024
  17. WindowHeight = 1000
  18. SidebarWidth = 220
  19.  
  20. ;Optional workaround for german keyboard layouts, see bottom of the script.
  21. ;Set to nonzero to enable.
  22. UseGermanKeyboardFix = 0
  23.  
  24. ;You probably don´t need to touch this.
  25. ;This could be helpful for non-english versions.
  26. ;If your Script Editor window is not called "Script Editor"
  27. ;you can change that here.
  28. ScriptEditorWindow = Script Editor
  29.  
  30. ;Settings stop here :) -------------------------------------------------------
  31.  
  32.  
  33.  
  34. txt_name = Scintilla1
  35. bor_name = Static3
  36. sdb_name = ListBox1
  37. lsn_name = Static2
  38. tsn_name = Edit1
  39. bt1_name = Button1
  40. bt2_name = Button2
  41. bt3_name = Button3
  42. bt4_name = Button4
  43.  
  44. defaults_saved = 0
  45.  
  46. sidebar_default_w = 196
  47. margin = 10
  48. margin_double = 20
  49. margin_triple = 30
  50. bottom_space = 50
  51.  
  52. ;-----------------------------------------------------------------------------
  53.  
  54. ;These are hotkeys, you can look up what other keys are here:
  55. ;http://www.autohotkey.com/docs/Hotkeys.htm
  56. #If WinActive(ScriptEditorWindow)
  57.     !1::win_restore()
  58.     !2::win_resize(WindowWidth, WindowHeight, SidebarWidth)
  59.     !3::win_resize(1400, 1000, 260)
  60.     ^s::Send !a
  61.     F12::game_start()
  62. #If
  63. #If AutoResize
  64.     F11::        
  65.         Send {F11}
  66.        
  67.         IfWinNotActive, %ScriptEditorWindow%
  68.         {
  69.             WinWaitActive, %ScriptEditorWindow%,,0.3
  70.             win_resize(WindowWidth, WindowHeight, SidebarWidth)
  71.         }
  72.     return
  73. #If
  74. ;-----------------------------------------------------------------------------
  75.  
  76. win_resize(w, h, sw)
  77. {
  78.     global
  79.     save_defaults()  
  80.    
  81.     diff_w := w - win_w
  82.    
  83.     ;Move and resize the window
  84.     WinMove, %ScriptEditorWindow%,,,, w, h
  85.    
  86.     ;Script Window and Buttons below
  87.     new_button_y := h-margin_triple-margin
  88.     ControlMove, %bt1_name%, bt1_x + diff_w, new_button_y, bt1_w, bt1_h, %ScriptEditorWindow%
  89.     ControlMove, %bt2_name%, bt2_x + diff_w, new_button_y, bt2_w, bt2_h, %ScriptEditorWindow%
  90.     ControlMove, %bt3_name%, bt3_x + diff_w, new_button_y, bt3_w, bt3_h, %ScriptEditorWindow%
  91.     ControlMove, %bt4_name%, bt4_x + diff_w, new_button_y, bt4_w, bt4_h, %ScriptEditorWindow%        
  92.    
  93.     new_script_x := sw+margin_double
  94.     new_script_w := w-sw-margin_triple
  95.     new_script_h := h-bottom_space-margin_triple+1
  96.     new_txt_x := txt_x + sw - sidebar_default_w - 2
  97.     ControlMove, %bor_name%, new_script_x, bor_y, new_script_w, new_script_h, %ScriptEditorWindow%
  98.     ControlMove, %txt_name%, new_txt_x, txt_y, new_script_w-3, new_script_h-4, %ScriptEditorWindow%
  99.    
  100.     ;Sidebar and script name
  101.     new_sidebar_y := 29 ;hides that scripts headline
  102.     new_sidebar_w := sw
  103.     new_sidebar_h := h-bottom_space-new_sidebar_y
  104.     ControlMove, %sdb_name%, sdb_x, new_sidebar_y, new_sidebar_w, new_sidebar_h, %ScriptEditorWindow%
  105.    
  106.     new_tsn_y := new_sidebar_y+new_sidebar_h+margin
  107.     ControlMove, %tsn_name%, tsn_x, new_tsn_y, tsn_w + sw - sidebar_default_w, tsn_h, %ScriptEditorWindow%            
  108.    
  109.     new_lsn_y := new_tsn_y + 4
  110.     ControlMove, %lsn_name%, lsn_x, new_lsn_y, lsn_w, lsn_h, %ScriptEditorWindow%
  111.  
  112.     win_center()
  113. }
  114. ;-----------------------------------------------------------------------------
  115.  
  116. win_restore()
  117. {
  118.     global
  119.     WinMove, %ScriptEditorWindow%,, win_x, win_y, win_w, win_h    
  120.     ControlMove, %bor_name%, bor_x, bor_y, bor_w, bor_h, %ScriptEditorWindow%
  121.     ControlMove, %txt_name%, txt_x, txt_y, txt_w, txt_h, %ScriptEditorWindow%
  122.     ControlMove, %bt1_name%, bt1_x, bt1_y, bt1_w, bt1_h, %ScriptEditorWindow%
  123.     ControlMove, %bt2_name%, bt2_x, bt2_y, bt2_w, bt2_h, %ScriptEditorWindow%
  124.     ControlMove, %bt3_name%, bt3_x, bt3_y, bt3_w, bt3_h, %ScriptEditorWindow%
  125.     ControlMove, %bt4_name%, bt4_x, bt4_y, bt4_w, bt4_h, %ScriptEditorWindow%
  126.     ControlMove, %sdb_name%, sdb_x, sdb_y, sdb_w, sdb_h, %ScriptEditorWindow%
  127.     ControlMove, %lsn_name%, lsn_x, lsn_y, lsn_w, lsn_h, %ScriptEditorWindow%
  128.     ControlMove, %tsn_name%, tsn_x, tsn_y, tsn_w, tsn_h, %ScriptEditorWindow%
  129.     win_center()
  130. }
  131. ;-----------------------------------------------------------------------------
  132.  
  133. save_defaults()
  134. {
  135.     global
  136.     if defaults_saved != 1
  137.     {
  138.         WinGetPos, win_x, win_y, win_w, win_h, %ScriptEditorWindow%
  139.         ControlGetPos, txt_x, txt_y, txt_w, txt_h, %txt_name%, %ScriptEditorWindow%
  140.         ControlGetPos, bor_x, bor_y, bor_w, bor_h, %bor_name%, %ScriptEditorWindow%
  141.         ControlGetPos, bt1_x, bt1_y, bt1_w, bt1_h, %bt1_name%, %ScriptEditorWindow%
  142.         ControlGetPos, bt2_x, bt2_y, bt2_w, bt2_h, %bt2_name%, %ScriptEditorWindow%
  143.         ControlGetPos, bt3_x, bt3_y, bt3_w, bt3_h, %bt3_name%, %ScriptEditorWindow%
  144.         ControlGetPos, bt4_x, bt4_y, bt4_w, bt4_h, %bt4_name%, %ScriptEditorWindow%
  145.         ControlGetPos, sdb_x, sdb_y, sdb_w, sdb_h, %sdb_name%, %ScriptEditorWindow%
  146.         ControlGetPos, lsn_x, lsn_y, lsn_w, lsn_h, %lsn_name%, %ScriptEditorWindow%
  147.         ControlGetPos, tsn_x, tsn_y, tsn_w, tsn_h, %tsn_name%, %ScriptEditorWindow%
  148.         defaults_saved = 1
  149.     }
  150. }
  151. ;-----------------------------------------------------------------------------
  152.  
  153. win_center()
  154. {
  155.     global
  156.     WinGetPos,,, ww, wh, %ScriptEditorWindow%
  157.     WinMove, %ScriptEditorWindow%,, (A_ScreenWidth/2)-(ww/2), (A_ScreenHeight/2)-(wh/2)
  158. }
  159. ;-----------------------------------------------------------------------------
  160.  
  161. game_start()
  162. {
  163.     global
  164.     ControlFocus, %bt1_name%, %ScriptEditorWindow%
  165.     Send {SPACE}
  166.     Send ^s
  167.     Send {F12}
  168. }
  169.  
  170. ;-----------------------------------------------------------------------------
  171.  
  172. ;Below is a AltGr + Q fix for german keyboard layouts.
  173. ;We can´t type an @ in script editor without toggling
  174. ;the line comment feature that is on CTRL + Q too.
  175. #if UseGermanKeyboardFix && WinActive(ScriptEditorWindow)
  176.     <^>!q::
  177.     ^!q::
  178.         save := clipboardall
  179.         clipboard = @
  180.         Send ^v
  181.         clipboard := save
  182.     return
  183. #if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement