Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .osf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"4d8e6d26-8cc4-4916-a349-53c5fc87a4c3","version":0,"attempts":21,"game_name":"Final Fantasy VI World's Collide","game_category":"Ultros League","window_x":1539,"window_y":586,"window_height":388,"window_width":416,"runs":[{"id":"d7f6c8dd-0c32-48a8-bb0d-6d31c30059ee","split_file_version":0,"total_time":6844552,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3863072,"current_duration":3863072},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":6844552,"current_duration":2981480}},"leaf_segments":null,"completed":false},{"id":"434f571b-802d-4ec9-8e81-8da7d99a8769","split_file_version":0,"total_time":0,"splits":{},"leaf_segments":null,"completed":false},{"id":"e8ab994e-965a-4d1c-8f63-680b88f58488","split_file_version":0,"total_time":5151654,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3625974,"current_duration":3625974},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5151654,"current_duration":1525680}},"leaf_segments":null,"completed":false},{"id":"da1ed76e-7104-4d19-9fa6-e3ab01b5890b","split_file_version":0,"total_time":5884904,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":4204444,"current_duration":4204444},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5884904,"current_duration":1680460}},"leaf_segments":null,"completed":false},{"id":"1e2317eb-e693-4102-8901-411f8048206e","split_file_version":0,"total_time":5356052,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3810011,"current_duration":3810011},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5356052,"current_duration":1546041}},"leaf_segments":null,"completed":false},{"id":"25fe2c27-0cef-4bf0-be0d-a1cc39bd729e","split_file_version":0,"total_time":5040039,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3492359,"current_duration":3492359},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5040039,"current_duration":1547680}},"leaf_segments":null,"completed":false},{"id":"26f1e4e8-c594-465c-83cc-4d233ec91565","split_file_version":0,"total_time":5276154,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":4094294,"current_duration":4094294},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5276154,"current_duration":1181860}},"leaf_segments":null,"completed":false},{"id":"c9d67d12-75dc-4d88-a2c1-cc5d3c202c6b","split_file_version":0,"total_time":5864942,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3783242,"current_duration":3783242},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5864942,"current_duration":2081700}},"leaf_segments":null,"completed":false},{"id":"8e4762a0-69eb-424b-8db4-9b9258a9e90a","split_file_version":0,"total_time":0,"splits":{},"leaf_segments":null,"completed":false},{"id":"d5e6f04c-491c-4d13-85bd-fd5ac0d29834","split_file_version":0,"total_time":5183477,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3527552,"current_duration":3527552},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5183477,"current_duration":1655925}},"leaf_segments":null,"completed":false},{"id":"ec6d4173-b4d0-4343-9d0d-fdc9eac54b17","split_file_version":0,"total_time":0,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":4959039,"current_duration":4959039}},"leaf_segments":null,"completed":false},{"id":"850a9b09-7fed-44e5-981b-46aa66f288e5","split_file_version":0,"total_time":4772269,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3671129,"current_duration":3671129},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":4772269,"current_duration":1101140}},"leaf_segments":null,"completed":false},{"id":"05f98b42-75ff-4100-8b38-d9f3694a4944","split_file_version":0,"total_time":5213407,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3908687,"current_duration":3908687},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5213407,"current_duration":1304720}},"leaf_segments":null,"completed":false},{"id":"36faea64-7549-42db-b67a-467494d7a222","split_file_version":0,"total_time":5895423,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":4018765,"current_duration":4018765},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5895423,"current_duration":1876657}},"leaf_segments":null,"completed":false},{"id":"d67f52e8-8fb6-46df-b7dc-2f711d0c8755","split_file_version":0,"total_time":5651004,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3105004,"current_duration":3105004},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5651004,"current_duration":2546000}},"leaf_segments":null,"completed":false},{"id":"8596e95d-5377-4733-be8e-f8c27cdedf7e","split_file_version":0,"total_time":5173226,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3277192,"current_duration":3277192},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5173226,"current_duration":1896034}},"leaf_segments":null,"completed":false},{"id":"e14e4ed4-3a23-44c5-a9dd-b9d50adde55e","split_file_version":0,"total_time":6003774,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":4053154,"current_duration":4053154},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":6003774,"current_duration":1950620}},"leaf_segments":null,"completed":false},{"id":"a75d5af6-8515-439d-8113-4fab4a23ae20","split_file_version":0,"total_time":4476763,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3006623,"current_duration":3006623},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":4476763,"current_duration":1470140}},"leaf_segments":null,"completed":false},{"id":"d558aa91-ca39-46c9-8253-9fbfdfd7444b","split_file_version":0,"total_time":0,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3698829,"current_duration":3698829}},"leaf_segments":null,"completed":false},{"id":"6efffb6c-7a06-4975-8f5b-05a020a0b02b","split_file_version":0,"total_time":5393626,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3805064,"current_duration":3805064},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5393626,"current_duration":1588561}},"leaf_segments":null,"completed":false}],"segments":[{"id":"22d0710b-5a73-443d-8fee-9d4725d865c2","name":"GO MODE","gold":3006623,"average":3772468,"pb":3805064,"children":[]},{"id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","name":"KefKILT","gold":1101140,"average":1745918,"pb":1588561,"children":[]}],"sob":4107763,"pb":{"id":"6efffb6c-7a06-4975-8f5b-05a020a0b02b","split_file_version":0,"total_time":5393626,"splits":{"22d0710b-5a73-443d-8fee-9d4725d865c2":{"split_segment_id":"22d0710b-5a73-443d-8fee-9d4725d865c2","current_cumulative":3805064,"current_duration":3805064},"397c03ca-30c5-442a-a40c-4f7f580f6a04":{"split_segment_id":"397c03ca-30c5-442a-a40c-4f7f580f6a04","current_cumulative":5393626,"current_duration":1588561}},"leaf_segments":null,"completed":false},"offset":0,"platform":""}
24 changes: 23 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ tasks:
echo 1

# If env WAILS_TAGS is set (e.g. by GHA), use it.
# Otherwise compute tags dynamically for local dev.
# Otherwise, compute tags dynamically for local dev.
WAILS_TAGS:
sh: |
set -euo pipefail
Expand Down Expand Up @@ -191,3 +191,25 @@ tasks:
platforms: [windows]
cmds:
- wails build -clean

package-default-skin:
desc: Zip folder into ./skin/default-skin.zip
vars:
SRC_DIR: '{{.SRC_DIR}}'
ZIP_PATH: "./skin/default-skin.zip"

cmds:
- cmd: |
set -e
mkdir -p "$(dirname "{{.ZIP_PATH}}")"
parent="$(cd "$(dirname "{{.SRC_DIR}}")" && pwd)"
base="$(basename "{{.SRC_DIR}}")"
(cd "$parent" && zip -r "$OLDPWD/{{.ZIP_PATH}}" "$base")
platforms: [ linux, darwin ]

- cmd: >
powershell -NoProfile -Command
"New-Item -ItemType Directory -Force -Path (Split-Path -Parent '{{.ZIP_PATH}}') | Out-Null;
if (Test-Path -LiteralPath '{{.ZIP_PATH}}') { Remove-Item '{{.ZIP_PATH}}' -Force };
Compress-Archive -LiteralPath '{{.SRC_DIR}}' -DestinationPath '{{.ZIP_PATH}}' -Force"
platforms: [ windows ]
5 changes: 3 additions & 2 deletions autosplitter/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"sync"

"github.com/zellydev-games/opensplit/command"
"github.com/zellydev-games/opensplit/dispatcher"
"github.com/zellydev-games/opensplit/logger"
)
Expand Down Expand Up @@ -95,7 +96,7 @@ func (s *Socket) Listen() {

version := int(packet[4])
ackRequested := int(packet[5]) == 1
command := dispatcher.Command(packet[6])
c := command.Command(packet[6])

if version != 1 {
logger.Errorf(logModule, "invalid version: %d", version)
Expand All @@ -105,7 +106,7 @@ func (s *Socket) Listen() {
continue
}

_, err = s.dispatcher.Dispatch(command, nil)
_, err = s.dispatcher.Dispatch(c, nil)
if err != nil {
if ackRequested {
sendAck(conn, addr, 2)
Expand Down
23 changes: 23 additions & 0 deletions command/commands.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package command

// Command bytes are sent to the Service.Dispatch method receiver to indicate the state machine should take some action.
type Command byte

const (
QUIT Command = iota
NEW
LOAD
EDIT
CANCEL
SUBMIT
CLOSE
RESET
SAVE
SPLIT
UNDO
SKIP
PAUSE
TOGGLEGLOBAL
FOCUS
HELLO
)
34 changes: 17 additions & 17 deletions config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"sync"

"github.com/zellydev-games/opensplit/dispatcher"
"github.com/zellydev-games/opensplit/command"
"github.com/zellydev-games/opensplit/keyinfo"
"github.com/zellydev-games/opensplit/logger"
)
Expand All @@ -14,12 +14,12 @@ const logModule = "config"
// Service holds configuration options so that Service.GetEnvironment can work for both backend and frontend.
type Service struct {
mu sync.Mutex
SpeedRunAPIBase string `json:"speed_run_API_base"`
KeyConfig map[dispatcher.Command]keyinfo.KeyData `json:"key_config"`
GlobalHotkeysActive bool `json:"global_hotkeys_active"`
SplitFileDir string `json:"splitfile_dir"`
SkinsDir string `json:"skins_dir"`
SelectedSkin string `json:"selected_skin"`
SpeedRunAPIBase string `json:"speed_run_API_base"`
KeyConfig map[command.Command]keyinfo.KeyData `json:"key_config"`
GlobalHotkeysActive bool `json:"global_hotkeys_active"`
SplitFileDir string `json:"splitfile_dir"`
SkinsDir string `json:"skins_dir"`
SelectedSkin string `json:"selected_skin"`
configUpdatedChannel chan<- *Service
}

Expand All @@ -29,7 +29,7 @@ func NewService(splitFileFir string, skinsDir string) (*Service, chan *Service)
SplitFileDir: splitFileFir,
SkinsDir: skinsDir,
SpeedRunAPIBase: "",
KeyConfig: map[dispatcher.Command]keyinfo.KeyData{},
KeyConfig: map[command.Command]keyinfo.KeyData{},
configUpdatedChannel: updateChannel,
}, updateChannel
}
Expand All @@ -48,24 +48,24 @@ func (s *Service) GetEnvironment() *Service {
}

// UpdateKeyBinding changes the ConfigPayload for the given command.
func (s *Service) UpdateKeyBinding(command dispatcher.Command, data keyinfo.KeyData) {
func (s *Service) UpdateKeyBinding(c command.Command, data keyinfo.KeyData) {
s.mu.Lock()
defer s.mu.Unlock()
s.KeyConfig[command] = data
s.KeyConfig[c] = data
s.sendUIBridgeUpdate()
logger.Infof(logModule, "updated key binding for command %v to %s", command, data.LocaleName)
logger.Infof(logModule, "updated key binding for c %v to %s", c, data.LocaleName)
}

// CreateDefaultConfig sets the service's options to reasonable defaults.
//
// Useful if the config file hasn't been created yet (first run)
func (s *Service) CreateDefaultConfig() {
s.KeyConfig = map[dispatcher.Command]keyinfo.KeyData{}
s.KeyConfig[dispatcher.SPLIT] = keyinfo.KeyData{}
s.KeyConfig[dispatcher.UNDO] = keyinfo.KeyData{}
s.KeyConfig[dispatcher.SKIP] = keyinfo.KeyData{}
s.KeyConfig[dispatcher.PAUSE] = keyinfo.KeyData{}
s.KeyConfig[dispatcher.RESET] = keyinfo.KeyData{}
s.KeyConfig = map[command.Command]keyinfo.KeyData{}
s.KeyConfig[command.SPLIT] = keyinfo.KeyData{}
s.KeyConfig[command.UNDO] = keyinfo.KeyData{}
s.KeyConfig[command.SKIP] = keyinfo.KeyData{}
s.KeyConfig[command.PAUSE] = keyinfo.KeyData{}
s.KeyConfig[command.RESET] = keyinfo.KeyData{}
s.sendUIBridgeUpdate()
logger.Infof(logModule, "created default config")
}
Expand Down
18 changes: 9 additions & 9 deletions config/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/zellydev-games/opensplit/dispatcher"
"github.com/zellydev-games/opensplit/command"
"github.com/zellydev-games/opensplit/keyinfo"
)

Expand Down Expand Up @@ -62,11 +62,11 @@ func TestUpdateKeyBinding(t *testing.T) {
ch := make(chan *Service, 1)

s := &Service{
KeyConfig: make(map[dispatcher.Command]keyinfo.KeyData),
KeyConfig: make(map[command.Command]keyinfo.KeyData),
configUpdatedChannel: ch,
}

cmd := dispatcher.SPLIT
cmd := command.SPLIT
data := keyinfo.KeyData{
KeyCode: 32,
LocaleName: "SPACE",
Expand Down Expand Up @@ -107,12 +107,12 @@ func TestCreateDefaultConfig(t *testing.T) {
}

// Required commands should always be present
required := []dispatcher.Command{
dispatcher.SPLIT,
dispatcher.UNDO,
dispatcher.SKIP,
dispatcher.PAUSE,
dispatcher.RESET,
required := []command.Command{
command.SPLIT,
command.UNDO,
command.SKIP,
command.PAUSE,
command.RESET,
}

for _, cmd := range required {
Expand Down
43 changes: 18 additions & 25 deletions dispatcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"sync"

"github.com/wailsapp/wails/v2/pkg/runtime"
"github.com/zellydev-games/opensplit/command"
"github.com/zellydev-games/opensplit/dto"
"github.com/zellydev-games/opensplit/logger"
)

Expand All @@ -19,27 +21,11 @@ type FolderProvider interface {
OpenSkinsDir()
}

// Command bytes are sent to the Service.Dispatch method receiver to indicate the state machine should take some action.
type Command byte

const (
QUIT Command = iota
NEW
LOAD
EDIT
CANCEL
SUBMIT
CLOSE
RESET
SAVE
SPLIT
UNDO
SKIP
PAUSE
TOGGLEGLOBAL
FOCUS
HELLO
)
type RepoProvider interface {
LoadSplitFile() (dto.SplitFile, error)
SaveSplitFile(dto.SplitFile) error
Export() error
}

// DispatchReply is sent in response to Dispatch
//
Expand All @@ -50,32 +36,35 @@ type DispatchReply struct {
}

type DispatchReceiver interface {
ReceiveDispatch(Command, *string) (DispatchReply, error)
ReceiveDispatch(command.Command, *string) (DispatchReply, error)
}

type Service struct {
mu sync.Mutex
receiver DispatchReceiver
runtime RuntimeProvider
folderProvider FolderProvider
repo RepoProvider
}

func NewService(receiver DispatchReceiver,
runtime RuntimeProvider,
folderProvider FolderProvider,
repo RepoProvider,
) *Service {
return &Service{
runtime: runtime,
receiver: receiver,
folderProvider: folderProvider,
repo: repo,
}
}

func (s *Service) Dispatch(command Command, payload *string) (DispatchReply, error) {
logger.Debugf(logModule, "dispatching command: %v", command)
func (s *Service) Dispatch(cmd command.Command, payload *string) (DispatchReply, error) {
logger.Debugf(logModule, "dispatching cmd: %v", cmd)
s.mu.Lock()
defer s.mu.Unlock()
return s.receiver.ReceiveDispatch(command, payload)
return s.receiver.ReceiveDispatch(cmd, payload)
}

func (s *Service) OpenSplitFileFolder() {
Expand All @@ -85,3 +74,7 @@ func (s *Service) OpenSplitFileFolder() {
func (s *Service) OpenSkinsFolder() {
s.folderProvider.OpenSkinsDir()
}

func (s *Service) ExportSplitFile(platform string) error {
return s.repo.Export()
}
12 changes: 8 additions & 4 deletions dispatcher/service_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package dispatcher

import "testing"
import (
"testing"

"github.com/zellydev-games/opensplit/command"
)

type mockDispatchReceiver struct{}

func (r mockDispatchReceiver) ReceiveDispatch(Command, *string) (DispatchReply, error) {
func (r mockDispatchReceiver) ReceiveDispatch(command.Command, *string) (DispatchReply, error) {
return DispatchReply{
Code: 69,
Message: "Nice.",
Expand All @@ -13,8 +17,8 @@ func (r mockDispatchReceiver) ReceiveDispatch(Command, *string) (DispatchReply,

func TestDispatch(t *testing.T) {
dr := mockDispatchReceiver{}
s := NewService(dr, nil, nil)
reply, _ := s.Dispatch(SPLIT, nil)
s := NewService(dr, nil, nil, nil)
reply, _ := s.Dispatch(command.SPLIT, nil)
if reply.Code != 69 || reply.Message != "Nice." {
t.Fatalf("Dispatch expected to return code 69 with message Nice. but got %v: %s", reply.Code, reply.Message)
}
Expand Down
1 change: 1 addition & 0 deletions dto/splitfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ type SplitFile struct {
SOB int64 `json:"sob"`
PB *Run `json:"pb"`
Offset int64 `json:"offset"`
Platform string `json:"platform"`
}
1 change: 1 addition & 0 deletions frontend/src/components/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function Config({ configPayload }: ConfigParams) {
useEffect(() => {
(async () => {
const as = await GetAvailableSkins();
console.log(as);
setAvailableSkins(as);
})();
}, []);
Expand Down
Loading