Skip to content

Commit

Permalink
liting pkg/app
Browse files Browse the repository at this point in the history
it actually uncomments some important code
  • Loading branch information
gucio321 committed Nov 27, 2024
1 parent 0454a2d commit 50b14d3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
23 changes: 10 additions & 13 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ func (a *App) render() {
}

func logErr(fmtErr string, args ...interface{}) {
msg := fmt.Sprintf(fmtErr, args...)
log.Print(msg)
dialog.Message(msg).Error()
log.Printf(fmtErr, args...)
dialog.Message(fmtErr, args...).Error()
}

func (a *App) createEditor(path *common.PathEntry, state []byte, x, y, w, h float32) {
Expand Down Expand Up @@ -303,8 +302,8 @@ func (a *App) onProjectPropertiesChanged(project *hsproject.Project) {
}
}

func (a *App) onPreferencesChanged(config *config.Config) {
a.config = config
func (a *App) onPreferencesChanged(cfg *config.Config) {
a.config = cfg
if err := a.config.Save(); err != nil {
logErr("after changing preferences, %s", err)
}
Expand Down Expand Up @@ -343,11 +342,9 @@ func (a *App) closeActiveEditor() {
}

func (a *App) closePopups() {
/*
a.projectPropertiesDialog.Cleanup()
a.aboutDialog.Cleanup()
a.preferencesDialog.Cleanup()
*/
a.projectPropertiesDialog.Cleanup()
a.aboutDialog.Cleanup()
a.preferencesDialog.Cleanup()
}

func (a *App) toggleConsole() {
Expand All @@ -356,9 +353,9 @@ func (a *App) toggleConsole() {

// CloseAllOpenWindows closes all opened windows
func (a *App) CloseAllOpenWindows() {
// a.closePopups()
// a.projectExplorer.Cleanup()
// a.mpqExplorer.Cleanup()
a.closePopups()
a.projectExplorer.Cleanup()
a.mpqExplorer.Cleanup()
a.focusedEditor = nil

for _, editor := range a.editors {
Expand Down
2 changes: 0 additions & 2 deletions pkg/app/app_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func (a *App) RestoreAppState(state hsstate.AppState) {
}

for _, editorState := range state.EditorWindows {
editorState := editorState

var path common.PathEntry

err := json.Unmarshal(editorState.Path, &path)
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Package hsapp contains HellSpawner's high-level application logic
// Package app contains HellSpawner's high-level application logic
package app
8 changes: 4 additions & 4 deletions pkg/app/menubar.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (a *App) projectMenu() *g.MenuWidget {
)

projectOpened := a.project != nil
enginePathSet := len(a.config.AbyssEnginePath) > 0
enginePathSet := a.config.AbyssEnginePath != ""

label := runAbyssEngine
if a.abyssWrapper.IsRunning() {
Expand Down Expand Up @@ -281,7 +281,7 @@ func (a *App) onHelpAboutClicked() {
func (a *App) onProjectRunClicked() {
if a.abyssWrapper.IsRunning() {
if err := a.abyssWrapper.Kill(); err != nil {
dialog.Message(err.Error()).Error()
dialog.Message("%v", err).Error()
}

return
Expand All @@ -290,7 +290,7 @@ func (a *App) onProjectRunClicked() {
a.console.Show()

if err := a.abyssWrapper.Launch(a.config, a.console); err != nil {
dialog.Message(err.Error()).Error()
dialog.Message("%v", err).Error()
}
}

Expand Down Expand Up @@ -410,7 +410,7 @@ func makeMenuID(name, group, shortcut string) string {
fmt3 = "%v\t(%v)%v%v%v"
)

if len(shortcut) > 0 {
if shortcut != "" {
return fmt.Sprintf(fmt3, name, shortcut, sep, group, name)
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (a *App) setupMasterWindow() {
}

func (a *App) determineBackgroundColor() color.RGBA {
const bitSize = 64
const bitSize = 32

result := a.config.BGColor

Expand All @@ -110,6 +110,7 @@ func (a *App) determineBackgroundColor() color.RGBA {
bg <<= 8
}

//nolint:gosec // this complains about intager size, but this number was created by strconv.ParseInt with bitsize 32
result = hsutil.Color(uint32(bg))
}

Expand Down

0 comments on commit 50b14d3

Please sign in to comment.