Skip to content

Commit

Permalink
Add ability to manage (read: remove) modloader manually (not critical…
Browse files Browse the repository at this point in the history
… enough for an RC)
  • Loading branch information
20kdc committed Dec 21, 2019
1 parent d683428 commit 9b6d3ac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
3 changes: 2 additions & 1 deletion credits.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ func (app *upApplication) ShowCredits(back framework.ButtonBehavior) {
if secretDeveloperModeCounter < 4 {
text = "developer mode will be toggled by going here " + strconv.Itoa(4 - secretDeveloperModeCounter) + " more times\n"
} else {
app.cachedPrimaryView = nil
app.config.DevMode = !app.config.DevMode
middle.WriteUpdaterConfig(app.config)
}
if !app.config.DevMode {
if !app.config.DevMode {
text += "developer mode is disabled"
} else {
text += "developer mode is enabled"
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

type upApplication struct {
gameInstance *ccmodupdater.GameInstance
// Reset this to nil whenever anything that affects the Primary View changes
cachedPrimaryView framework.UILayoutElement
config middle.UpdaterConfig
mainContainer *framework.UISlideTransitionContainer
window frenyard.Window
Expand Down
10 changes: 10 additions & 0 deletions optionsMenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func (app *upApplication) ShowOptionsMenu(back framework.ButtonBehavior) {
},
}),
},
{
Element: design.ListItem(design.ListItemDetails{
Text: "Show Modloader",
Subtext: "Show the installed modloader",
Click: func () {
app.GSRightwards()
app.ShowPackageView(backHere, "ccloader")
},
}),
},
{
Grow: 1,
},
Expand Down
17 changes: 8 additions & 9 deletions packageView.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import (
)

// ShowPackageView shows a dialog for a package.
// backHeavy is used if nothing actually happened.
// backLight is used if something happened (the ShowPackageView return call has both set to the same value).
// This allows preserving state in the PrimaryView.
func (app *upApplication) ShowPackageView(backHeavy framework.ButtonBehavior, backLight framework.ButtonBehavior, pkg string) {
func (app *upApplication) ShowPackageView(back framework.ButtonBehavior, pkg string) {
// Construct a package context here and use it to sanity-check some things.
// It also makes a nice cup-holder for the local/remote repositories.
txCtx := ccmodupdater.PackageTXContext{
Expand All @@ -28,9 +25,9 @@ func (app *upApplication) ShowPackageView(backHeavy framework.ButtonBehavior, ba
// No latest package = no information.
if latestPkg == nil {
if middle.InternetConnectionWarning {
app.MessageBox("Package not available", "The package '" + pkg + "' could not be found.\n\nAs you have ended up here, the package probably had to exist in some form.\nThis error is probably because CCUpdaterUI was unable to retrieve remote packages.\n\n1. Check your internet connection\n2. Try restarting CCUpdaterUI\n3. Contact us", backLight)
app.MessageBox("Package not available", "The package '" + pkg + "' could not be found.\n\nAs you have ended up here, the package probably had to exist in some form.\nThis error is probably because CCUpdaterUI was unable to retrieve remote packages.\n\n1. Check your internet connection\n2. Try restarting CCUpdaterUI\n3. Contact us", back)
} else {
app.MessageBox("I just don't know what went wrong...", "The package '" + pkg + "' could not be found.\nYou should never be able to see this dialog in normal operation.", backLight)
app.MessageBox("I just don't know what went wrong...", "The package '" + pkg + "' could not be found.\nYou should never be able to see this dialog in normal operation.", back)
}
return
}
Expand Down Expand Up @@ -67,8 +64,9 @@ func (app *upApplication) ShowPackageView(backHeavy framework.ButtonBehavior, ba
buttons = append(buttons, design.ButtonAction(removeTheme, buttonText, func () {
app.GSDownwards()
app.PerformTransaction(func () {
app.cachedPrimaryView = nil
app.GSUpwards()
app.ShowPackageView(backHeavy, backHeavy, pkg)
app.ShowPackageView(back, pkg)
}, removeTx)
}))
}
Expand All @@ -90,8 +88,9 @@ func (app *upApplication) ShowPackageView(backHeavy framework.ButtonBehavior, ba
buttons = append(buttons, design.ButtonAction(buttonColour, buttonText, func () {
app.GSDownwards()
app.PerformTransaction(func () {
app.cachedPrimaryView = nil
app.GSUpwards()
app.ShowPackageView(backHeavy, backHeavy, pkg)
app.ShowPackageView(back, pkg)
}, installTx)
}))
}
Expand Down Expand Up @@ -136,6 +135,6 @@ func (app *upApplication) ShowPackageView(backHeavy framework.ButtonBehavior, ba

app.Teleport(design.LayoutDocument(design.Header{
Title: latestPkg.Metadata().HumanName(),
Back: backLight,
Back: back,
}, fullPanel, true))
}
29 changes: 9 additions & 20 deletions primaryView.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
// ShowPrimaryView shows the "Primary View" (the mod list right now)
func (app *upApplication) ShowPrimaryView() {

// This is used to preserve the state when nothing has changed (for example, when browsing).
var thePage framework.UILayoutElement
if app.cachedPrimaryView != nil {
app.Teleport(app.cachedPrimaryView)
return
}

slots := []framework.FlexboxSlot{}

Expand All @@ -32,9 +34,6 @@ func (app *upApplication) ShowPrimaryView() {
app.ShowPackageView(func () {
app.GSLeftwards()
app.ShowPrimaryView()
}, func () {
app.GSLeftwards()
app.Teleport(thePage)
}, pkgID)
}
}
Expand Down Expand Up @@ -98,9 +97,6 @@ func (app *upApplication) ShowPrimaryView() {
app.ShowPackageView(func () {
app.GSLeftwards()
app.ShowPrimaryView()
}, func () {
app.GSLeftwards()
app.Teleport(thePage)
}, pkgIDLocal)
},
})
Expand All @@ -112,14 +108,11 @@ func (app *upApplication) ShowPrimaryView() {
Grow: 1,
})

// Keep copies of whatever the options menu can change.
// If we're returned to with something changed, refresh.
// Otherwise try to reuse the element; it's better-performant and preserves state.
thePresentStateOfDevMode := app.config.DevMode

thePage = design.LayoutDocument(design.Header{
// This cached element is used to boost performance when possible.
app.cachedPrimaryView = design.LayoutDocument(design.Header{
Title: "Mods",
Back: func () {
app.cachedPrimaryView = nil
app.GSLeftwards()
app.ResetWithGameLocation(false, middle.GameFinderVFSPathDefault)
},
Expand All @@ -129,16 +122,12 @@ func (app *upApplication) ShowPrimaryView() {
app.GSRightwards()
app.ShowOptionsMenu(func () {
app.GSLeftwards()
if thePresentStateOfDevMode != app.config.DevMode {
app.ShowPrimaryView()
} else {
app.Teleport(thePage)
}
app.ShowPrimaryView()
})
},
}, framework.NewUIFlexboxContainerPtr(framework.FlexboxContainer{
DirVertical: true,
Slots: slots,
}), true)
app.Teleport(thePage)
app.Teleport(app.cachedPrimaryView)
}

0 comments on commit 9b6d3ac

Please sign in to comment.