From ec4949bc1bab1dd53b9520b0d7855198d98150b0 Mon Sep 17 00:00:00 2001 From: Tim Sarbin Date: Sat, 26 Oct 2019 17:30:00 -0400 Subject: [PATCH] Moved files around to allow running from root path --- .gitignore | 4 +- StringUtils.go => Common/StringUtils.go | 2 +- Engine.go => Core/Engine.go | 8 +-- README.md | 2 +- Sound/SoundEntry.go | 68 +++++++++++++++++++++++++ SoundEntry.go | 67 ------------------------ cmd/Client/main.go => main.go | 6 +-- 7 files changed, 80 insertions(+), 77 deletions(-) rename StringUtils.go => Common/StringUtils.go (97%) rename Engine.go => Core/Engine.go (97%) create mode 100644 Sound/SoundEntry.go delete mode 100644 SoundEntry.go rename cmd/Client/main.go => main.go (87%) diff --git a/.gitignore b/.gitignore index e426a28f..54001625 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ **/*__debug_bin -.vscode/*.* +.vscode/**/* **/Client.exe **/Client +.idea/**/* +.vs/**/* \ No newline at end of file diff --git a/StringUtils.go b/Common/StringUtils.go similarity index 97% rename from StringUtils.go rename to Common/StringUtils.go index f45f41c1..f412d22d 100644 --- a/StringUtils.go +++ b/Common/StringUtils.go @@ -1,4 +1,4 @@ -package OpenDiablo2 +package Common import "strconv" diff --git a/Engine.go b/Core/Engine.go similarity index 97% rename from Engine.go rename to Core/Engine.go index 7a1ec7d1..6952287d 100644 --- a/Engine.go +++ b/Core/Engine.go @@ -1,4 +1,4 @@ -package OpenDiablo2 +package Core import ( "encoding/json" @@ -37,7 +37,7 @@ type Engine struct { Settings EngineConfig // Engine configuration settings from json file Files map[string]string // Map that defines which files are in which MPQs Palettes map[Palettes.Palette]Common.Palette // Color palettes - SoundEntries map[string]SoundEntry // Sound configurations + SoundEntries map[string]Sound.SoundEntry // Sound configurations LoadingSprite *Common.Sprite // The sprite shown when loading stuff loadingProgress float64 // LoadingProcess is a range between 0.0 and 1.0. If set, loading screen displays. stepLoadingSize float64 // The size for each loading step @@ -148,13 +148,13 @@ func (v *Engine) loadPalettes() { func (v *Engine) loadSoundEntries() { log.Println("loading sound configurations") - v.SoundEntries = make(map[string]SoundEntry) + v.SoundEntries = make(map[string]Sound.SoundEntry) soundData := strings.Split(string(v.LoadFile(ResourcePaths.SoundSettings)), "\r\n")[1:] for _, line := range soundData { if len(line) == 0 { continue } - soundEntry := CreateSoundEntry(line) + soundEntry := Sound.CreateSoundEntry(line) v.SoundEntries[soundEntry.Handle] = soundEntry } } diff --git a/README.md b/README.md index ac9fabc5..4e95252e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ On windows this folder will most likely be in `C:\\users\\(you)\\go\\src\\github In the root folder, run `go get -d` to pull down all dependencies. -To run the project, run `go run ./cmd/Client` from the root folder. +To run the project, run `go run .` from the root folder. You can also open the root folder in VSCode. Make sure you have the `ms-vscode.go` plugin installed. diff --git a/Sound/SoundEntry.go b/Sound/SoundEntry.go new file mode 100644 index 00000000..ddc73d6d --- /dev/null +++ b/Sound/SoundEntry.go @@ -0,0 +1,68 @@ +package Sound + +import ( + "github.com/essial/OpenDiablo2/Common" + "strings" +) + +// SoundEntry represents a sound entry +type SoundEntry struct { + Handle string + Index int + FileName string + Volume byte + GroupSize uint8 + Loop bool + FadeIn uint8 + FadeOut uint8 + DeferInst uint8 + StopInst uint8 + Duration uint8 + Compound int8 + Reverb bool + Falloff uint8 + Cache uint8 + AsyncOnly bool + Priority uint8 + Stream uint8 + Stereo uint8 + Tracking uint8 + Solo uint8 + MusicVol uint8 + Block1 int + Block2 int + Block3 int +} + +// CreateSoundEntry creates a sound entry based on a sound row on sounds.txt +func CreateSoundEntry(soundLine string) SoundEntry { + props := strings.Split(soundLine, "\t") + result := SoundEntry{ + Handle: props[0], + Index: Common.StringToInt(props[1]), + FileName: props[2], + Volume: Common.StringToUint8(props[3]), + GroupSize: Common.StringToUint8(props[4]), + Loop: Common.StringToUint8(props[5]) == 1, + FadeIn: Common.StringToUint8(props[6]), + FadeOut: Common.StringToUint8(props[7]), + DeferInst: Common.StringToUint8(props[8]), + StopInst: Common.StringToUint8(props[9]), + Duration: Common.StringToUint8(props[10]), + Compound: Common.StringToInt8(props[11]), + Reverb: Common.StringToUint8(props[12]) == 1, + Falloff: Common.StringToUint8(props[13]), + Cache: Common.StringToUint8(props[14]), + AsyncOnly: Common.StringToUint8(props[15]) == 1, + Priority: Common.StringToUint8(props[16]), + Stream: Common.StringToUint8(props[17]), + Stereo: Common.StringToUint8(props[18]), + Tracking: Common.StringToUint8(props[19]), + Solo: Common.StringToUint8(props[20]), + MusicVol: Common.StringToUint8(props[21]), + Block1: Common.StringToInt(props[22]), + Block2: Common.StringToInt(props[23]), + Block3: Common.StringToInt(props[24]), + } + return result +} diff --git a/SoundEntry.go b/SoundEntry.go deleted file mode 100644 index 680dd9b3..00000000 --- a/SoundEntry.go +++ /dev/null @@ -1,67 +0,0 @@ -package OpenDiablo2 - -import ( - "strings" -) - -// SoundEntry represents a sound entry -type SoundEntry struct { - Handle string - Index int - FileName string - Volume byte - GroupSize uint8 - Loop bool - FadeIn uint8 - FadeOut uint8 - DeferInst uint8 - StopInst uint8 - Duration uint8 - Compound int8 - Reverb bool - Falloff uint8 - Cache uint8 - AsyncOnly bool - Priority uint8 - Stream uint8 - Stereo uint8 - Tracking uint8 - Solo uint8 - MusicVol uint8 - Block1 int - Block2 int - Block3 int -} - -// CreateSoundEntry creates a sound entry based on a sound row on sounds.txt -func CreateSoundEntry(soundLine string) SoundEntry { - props := strings.Split(soundLine, "\t") - result := SoundEntry{ - Handle: props[0], - Index: StringToInt(props[1]), - FileName: props[2], - Volume: StringToUint8(props[3]), - GroupSize: StringToUint8(props[4]), - Loop: StringToUint8(props[5]) == 1, - FadeIn: StringToUint8(props[6]), - FadeOut: StringToUint8(props[7]), - DeferInst: StringToUint8(props[8]), - StopInst: StringToUint8(props[9]), - Duration: StringToUint8(props[10]), - Compound: StringToInt8(props[11]), - Reverb: StringToUint8(props[12]) == 1, - Falloff: StringToUint8(props[13]), - Cache: StringToUint8(props[14]), - AsyncOnly: StringToUint8(props[15]) == 1, - Priority: StringToUint8(props[16]), - Stream: StringToUint8(props[17]), - Stereo: StringToUint8(props[18]), - Tracking: StringToUint8(props[19]), - Solo: StringToUint8(props[20]), - MusicVol: StringToUint8(props[21]), - Block1: StringToInt(props[22]), - Block2: StringToInt(props[23]), - Block3: StringToInt(props[24]), - } - return result -} diff --git a/cmd/Client/main.go b/main.go similarity index 87% rename from cmd/Client/main.go rename to main.go index c8163c08..5bb39630 100644 --- a/cmd/Client/main.go +++ b/main.go @@ -1,19 +1,19 @@ package main import ( + "github.com/essial/OpenDiablo2/Core" "log" - "github.com/essial/OpenDiablo2" "github.com/essial/OpenDiablo2/MPQ" "github.com/hajimehoshi/ebiten" ) -var d2Engine *OpenDiablo2.Engine +var d2Engine *Core.Engine func main() { log.Println("OpenDiablo2 - Open source Diablo 2 engine") MPQ.InitializeCryptoBuffer() - d2Engine = OpenDiablo2.CreateEngine() + d2Engine = Core.CreateEngine() ebiten.SetCursorVisible(false) ebiten.SetFullscreen(d2Engine.Settings.FullScreen) ebiten.SetRunnableInBackground(d2Engine.Settings.RunInBackground)