Skip to content
This repository has been archived by the owner on Feb 10, 2019. It is now read-only.

Commit

Permalink
Progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
pixaline committed Feb 11, 2018
1 parent a81e3fc commit 3b0b4a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
29 changes: 22 additions & 7 deletions BardMacroPlayer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ReadSettings() {

global fileSelectionOpen

global SongProgressBar
global FileSelectionControl
global FileLoadedControl
global StopControl
Expand Down Expand Up @@ -114,7 +115,7 @@ MakeMainWindow() {
global MainHwnd

playWidth := 250
playHeight := 90
playHeight := 95

Gui, PlayWindow: New, +hwndMainHwnd +ToolWindow +AlwaysOnTop
Gui, PlayWindow:+Owner +OwnDialogs
Expand All @@ -137,14 +138,15 @@ MakeMainWindow() {
Gui, Font, s8 w400, Segoe UI
Gui, Add, Text, ys w180 vFileLoadedControl, [ Bard Macro Player %Version% ]`n by Freya Katva @ Ultros

Gui, Add, Slider, ToolTip Thick10 vOctaveShift gOctaveSlider Range-4-4 x0 y60 w80, 0
Gui, Add, Text, x190 y56 cBlue gLaunchGithub, Project site
Gui, Add, Slider, ToolTip Section Thick10 vOctaveShift gOctaveSlider Range-4-4 x0 y65 w80, 0
Gui, Add, Progress, ys w150 h8 c222222 BackgroundCCCCCC vSongProgressBar

OnMessage(0x111, "MainWindowCommand")
OnMessage(0x203, "MainWindowDoubleClick")
OnMessage(0x201, "MainWindowDown")

Menu, AppMenu, Add, Parsed keys, ShowParsedKeyboard
Menu, AppMenu, Add, Project site, LaunchGithub
Menu, AppMenu, Add, Exit, ExitApplication
Menu, MainMenu, Add, App, :AppMenu
Gui, Menu, MainMenu
Expand All @@ -161,6 +163,7 @@ OctaveSlider() {
}
StopSubmit() {
Gui, Submit, NoHide
SetTimer, UpdateProgressBar, Off
if(currentPlayer) {
LoadFile(currentPlayer.filename, currentPlayer.trackIndex)
}
Expand All @@ -171,9 +174,11 @@ PausePlaySubmit() {
if(currentPlayer) {
if(currentPlayer.IsPlaying()) {
currentPlayer.Pause()
SetTimer, UpdateProgressBar, Off
} else {
currentPlayer.Play()
WinActivate, ahk_class FFXIVGAME
SetTimer, UpdateProgressBar, 100
}
}
UpdateMainWindow()
Expand Down Expand Up @@ -222,15 +227,15 @@ ReturnApplication() {

SetPlayButtonsVisibility(visible) {
v := (visible ? 1 : 0)
GuiControl, Show%v%, StopControl
GuiControl, Show%v%, PlayPauseControl
GuiControl, PlayWindow:Show%v%, StopControl
GuiControl, PlayWindow:Show%v%, PlayPauseControl
}

SetPlayPauseButton(play) {
if(play) {
GuiControl,, PlayPauseControl, 4
GuiControl,PlayWindow:, PlayPauseControl, 4
} else {
GuiControl,, PlayPauseControl, `;
GuiControl,PlayWindow:, PlayPauseControl, `;
}
}

Expand Down Expand Up @@ -287,6 +292,15 @@ MainWindowDown(wParam, lParam, msg := 0, hwnd := 0) {
}
}

UpdateProgressBar() {
if(currentPlayer) {
prog := Floor(currentPlayer.GetProgress() * 100)
GuiControl,PlayWindow:, SongProgressBar, % prog
} else {
GuiControl,PlayWindow:, SongProgressBar, 0
}
}

UpdateSelectedFile() {
text := currentPlayer.filename
if(currentPlayer.trackIndex > 0) {
Expand All @@ -305,6 +319,7 @@ UpdateSelectedFile() {
}

UpdateMainWindow() {
UpdateProgressBar()
SetPlayButtonsVisibility((currentPlayer != 0))
if(currentPlayer) {
text := ""
Expand Down
7 changes: 7 additions & 0 deletions notePlayer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class TxtPlayer extends BasePlayer
return this.txt.numNotes
}

GetProgress() {
return ((this.noteIndex-1) / (this.GetNumNotes()-1))
}

GetNote(note := -1) {
if(note == -1) {
note := this.noteIndex
Expand Down Expand Up @@ -120,6 +124,9 @@ class MidiPlayer extends BasePlayer
track := this.midi.midiTracks[this.trackIndex]
return track
}
GetProgress() {
return ((this.noteIndex-1) / (this.GetNumNotes()-1))
}

GetNumNotes() {
return this.GetTrack().trackNumNotes
Expand Down

0 comments on commit 3b0b4a5

Please sign in to comment.