Skip to content

Commit

Permalink
Merge branch 'feature/ui_improvements'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tischel committed Nov 1, 2019
2 parents fada25a + 42ff42f commit 9335f1b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TSplitter v0.2.0
# TSplitter v0.2.1
A tool that adds some features to https://github.com/Toufool/Auto-Split used in conjuction with https://github.com/LiveSplit
You need AutoHotkey to use this program (Download from https://www.autohotkey.com/)

Expand Down
32 changes: 22 additions & 10 deletions TSplitter.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#SingleInstance force

Version := "0.2.0"
Version := "0.2.1"

; Read saved key binds
IniRead, AutosplitSplit, TSplitter.ini, AutoSplit, Split
Expand Down Expand Up @@ -29,10 +29,10 @@ Gui, 1:Add, Text, x20 y29, Split/Start
Gui, 1:Add, Text, , Reset
Gui, 1:Add, Text, , Undo
Gui, 1:Add, Text, , Skip
Gui, 1:Add, Hotkey, x80 y25 w70 vAutosplitSplitHotkey, %AutosplitSplit%
Gui, 1:Add, Hotkey, w70 vAutosplitResetHotkey, %AutosplitReset%
Gui, 1:Add, Hotkey, w70 vAutosplitUndoHotkey, %AutosplitUndo%
Gui, 1:Add, Hotkey, w70 vAutosplitSkipHotkey, %AutosplitSkip%
Gui, 1:Add, Hotkey, x80 y25 w70 vAutosplitSplitHotkey gOnChange, %AutosplitSplit%
Gui, 1:Add, Hotkey, w70 vAutosplitResetHotkey gOnChange, %AutosplitReset%
Gui, 1:Add, Hotkey, w70 vAutosplitUndoHotkey gOnChange, %AutosplitUndo%
Gui, 1:Add, Hotkey, w70 vAutosplitSkipHotkey gOnChange, %AutosplitSkip%

Gui, 1:Font, bold
Gui, 1:Add, GroupBox, x165 y5 w150 h130, LiveSplit Keybinds
Expand All @@ -42,16 +42,16 @@ Gui, 1:Add, Text, x175 y29, Split/Start
Gui, 1:Add, Text, , Reset
Gui, 1:Add, Text, , Undo
Gui, 1:Add, Text, , Skip
Gui, 1:Add, Hotkey, x235 y25 w70 vLivesplitSplitHotkey, %LivesplitSplit%
Gui, 1:Add, Hotkey, w70 vLivesplitResetHotkey, %LivesplitReset%
Gui, 1:Add, Hotkey, w70 vLivesplitUndoHotkey, %LivesplitUndo%
Gui, 1:Add, Hotkey, w70 vLivesplitSkipHotkey, %LivesplitSkip%
Gui, 1:Add, Hotkey, x235 y25 w70 vLivesplitSplitHotkey gOnChange, %LivesplitSplit%
Gui, 1:Add, Hotkey, w70 vLivesplitResetHotkey gOnChange, %LivesplitReset%
Gui, 1:Add, Hotkey, w70 vLivesplitUndoHotkey gOnChange, %LivesplitUndo%
Gui, 1:Add, Hotkey, w70 vLivesplitSkipHotkey gOnChange, %LivesplitSkip%

Gui, 1:Font, bold
Gui, 1:Add, GroupBox, x10 y140 w305 h50, AutoSplit images folder

Gui, 1:Font, norm
Gui, 1:Add, Edit, x20 y160 w261 vAutosplitFolderTextfield, %AutosplitFolder%
Gui, 1:Add, Edit, x20 y160 w261 vAutosplitFolderTextfield gOnChange, %AutosplitFolder%
Gui, 1:Add, Button, x+-1 y159 w30 h23 gSelectFolder, ...

Gui, 1:Font, bold
Expand All @@ -68,7 +68,9 @@ Gui, 1:Menu, MyMenuBar

Gui, 1:Show

saveButtonAdded := false
ControlFocus, ..., TSplitter v%Version%
OnMessage(0x201, "WM_LBUTTONDOWN")

; Set keybinds
if (AutosplitSplit != "ERROR" and AutosplitSplit != "") {
Expand Down Expand Up @@ -122,6 +124,12 @@ IfExist, %AutosplitFolder%
}
Return

OnChange:
if (saveButtonAdded = false) {
Gui, 1:Add, Button, x10 y195 w305 h50 gReloadScript, Save
}
Return

Split:
delay := splitDelays[splitIndex]
Sleep, %delay%
Expand Down Expand Up @@ -241,3 +249,7 @@ ShowAbout:
GuiClose:
SaveKeybinds()
ExitApp

WM_LBUTTONDOWN() {
DllCall("SetFocus", "Ptr", 0)
}
141 changes: 86 additions & 55 deletions TSplitterEditor.ahk
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#SingleInstance force

Version := "0.2.0"
Version := "0.2.1"
SetFormat, float, 0.0

; Split window variables
SplitImagePicture :=
SplitImagePathTextfield :=
SplitNameTextfield :=
SplitProbabilityTextfield :=
Expand Down Expand Up @@ -294,6 +295,9 @@ Swap(index1, index2)

ShowSplitWindow()
{
Gui, 2:Destroy
Gui, 1:Default

order :=
imagePath :=
name :=
Expand All @@ -303,7 +307,9 @@ ShowSplitWindow()
masked := false
fake := false

if (SelectedSplitIndex > 0)
rowCount := LV_GetCount()

if (SelectedSplitIndex > 0)
{
LV_GetText(order, SelectedSplitIndex, 1)
LV_GetText(name, SelectedSplitIndex, 2)
Expand All @@ -321,30 +327,44 @@ ShowSplitWindow()
}

title := (SelectedSplitIndex > 0 ? "Edit split #"order : "New Split")
Gui, 2:New, +Owner -Resize, %title%
Gui, 2:Add, Text, y20, Image path:
Gui, 2:Add, Edit, x80 y5 w277 h40 vSplitImagePathTextfield, %imagePath%
Gui, 2:Add, Button, x+-1 y4 w30 h42 gSelectImage, ...
Gui, 2:New, +Owner +Resize, %title%

if (imagePath) {
Gui, 2:Add, Picture, x50 y10 w300 h-1 vSplitImagePicture, %imagePath%
}
Gui, 2:Add, Text, x10 y+20, Image path:
Gui, 2:Add, Edit, x80 y+-25 w277 h40 vSplitImagePathTextfield, %imagePath%
Gui, 2:Add, Button, x+-1 y+-41 w30 h42 gSelectImage, ...

Gui, 2:Add, Text, x10 y54, Split name:
Gui, 2:Add, Edit, x80 y50 w305 vSplitNameTextfield, %name%
Gui, 2:Add, Text, x10 y+10, Split name:
Gui, 2:Add, Edit, x80 y+-14 w305 vSplitNameTextfield, %name%

Gui, 2:Add, Text, x10 y85, Probability:
Gui, 2:Add, Edit, x70 y81 w50 vSplitProbabilityTextfield Limit3 Number, %probabillty%
Gui, 2:Add, Text, x10 y+20, Probability:
Gui, 2:Add, Edit, x70 y+-15 w50 vSplitProbabilityTextfield Limit3 Number, %probabillty%
Gui, 2:Add, UpDown, 0x80 Range1-100, %probabillty%

Gui, 2:Add, Text, x140 y85, Pause time:
Gui, 2:Add, Edit, x205 y81 w60 vSplitPauseTimeTextfield Limit4 Number, %pauseTime%
Gui, 2:Add, Text, x140 y+-19, Pause time:
Gui, 2:Add, Edit, x205 y+-15 w60 vSplitPauseTimeTextfield Limit4 Number, %pauseTime%
Gui, 2:Add, UpDown, 0x80 Range0-9999, %pauseTime%

Gui, 2:Add, Text, x285 y85, Delay:
Gui, 2:Add, Edit, x325 y81 w60 vSplitDelayTextfield Limit5 Number, %delay%
Gui, 2:Add, Text, x285 y+-19, Delay:
Gui, 2:Add, Edit, x325 y+-15 w60 vSplitDelayTextfield Limit5 Number, %delay%
Gui, 2:Add, UpDown, 0x80 Range0-99999, %delay%

Gui, 2:Add, CheckBox, x100 y115 vSplitMaskedCheck Checked%masked%, Masked image
Gui, 2:Add, CheckBox, x220 y115 vSplitFakeCheck Checked%fake%, Fake split
Gui, 2:Add, CheckBox, x100 y+20 vSplitMaskedCheck Checked%masked%, Masked image
Gui, 2:Add, CheckBox, x220 y+-12 vSplitFakeCheck Checked%fake%, Fake split

Gui, 2:Add, Button, x10 y150 w377 h30 gSaveEditedSplit, Save
Gui, 2:Add, Button, x100 y+30 w200 h30 gSaveEditedSplit, Save

if (SelectedSplitIndex > 1)
{
Gui, 2:Add, Button, x10 y+-30 w30 h30 gEditPreviousSplit, <
}

if (SelectedSplitIndex > 0 and SelectedSplitIndex < rowCount)
{
Gui, 2:Add, Button, x355 y+-30 w30 h30 gEditNextSplit, >
}

Gui, 2:Show
}
Expand All @@ -361,52 +381,63 @@ SelectImage:
GuiControlGet, imagePath, , SplitImagePathTextfield
FileSelectFile, imagePath, ,%imagePath%, Select splt image, PNG Images (*.png)
GuiControl, , SplitImagePathTextfield, %imagePath%
GuiControl, , SplitImagePicture, %imagePath%
Return

EditPreviousSplit:
SelectedSplitIndex := SelectedSplitIndex - 1
ShowSplitWindow()
Return

EditNextSplit:
SelectedSplitIndex := SelectedSplitIndex + 1
ShowSplitWindow()
Return

SaveEditedSplit:
; validate name
GuiControlGet, name, , SplitNameTextfield
if (!name or name = "") {
MsgBox, Invalid split name!
Return
}
; validate name
GuiControlGet, name, , SplitNameTextfield
if (!name or name = "") {
MsgBox, Invalid split name!
Return
}

; validate path
GuiControlGet, imagePath, , SplitImagePathTextfield
IfNotExist, %imagePath%
{
MsgBox, Couldn't find an image at "%imagePath%"!
Return
}
; validate path
GuiControlGet, imagePath, , SplitImagePathTextfield
IfNotExist, %imagePath%
{
MsgBox, Couldn't find an image at "%imagePath%"!
Return
}

IfNotInString, imagePath, .png
{
MsgBox, Only PNG images accepted!
Return
}
IfNotInString, imagePath, .png
{
MsgBox, Only PNG images accepted!
Return
}

; get values
GuiControlGet, probabillty, , SplitProbabilityTextfield
GuiControlGet, pauseTime, , SplitPauseTimeTextfield
GuiControlGet, delay, , SplitDelayTextfield
GuiControlGet, masked, , SplitMaskedCheck
maskedText := (masked = 1 ? "Yes" : "No")
GuiControlGet, fake, , SplitFakeCheck
fakeText := (fake = 1 ? "Yes" : "No")
; get values
GuiControlGet, probabillty, , SplitProbabilityTextfield
GuiControlGet, pauseTime, , SplitPauseTimeTextfield
GuiControlGet, delay, , SplitDelayTextfield
GuiControlGet, masked, , SplitMaskedCheck
maskedText := (masked = 1 ? "Yes" : "No")
GuiControlGet, fake, , SplitFakeCheck
fakeText := (fake = 1 ? "Yes" : "No")

Gui, 2:Destroy
Gui, 1:Default
Gui, 2:Destroy
Gui, 1:Default

; save
if (SelectedSplitIndex = -1)
{
rowCount := LV_GetCount() + 1
LV_Add(, rowCount, name, probabillty, pauseTime, delay, maskedText, fakeText, imagePath)
}
else
{
LV_Modify(SelectedSplitIndex, , SelectedSplitIndex, name, probabillty, pauseTime, delay, maskedText, fakeText, imagePath)
}
; save
if (SelectedSplitIndex = -1)
{
rowCount := LV_GetCount() + 1
LV_Add(, rowCount, name, probabillty, pauseTime, delay, maskedText, fakeText, imagePath)
}
else
{
LV_Modify(SelectedSplitIndex, , SelectedSplitIndex, name, probabillty, pauseTime, delay, maskedText, fakeText, imagePath)
}

Return

Expand Down

0 comments on commit 9335f1b

Please sign in to comment.