diff --git a/frontend/src/pages/Server.tsx b/frontend/src/pages/Server.tsx index 5feae43..d33e1a0 100644 --- a/frontend/src/pages/Server.tsx +++ b/frontend/src/pages/Server.tsx @@ -31,6 +31,7 @@ import {Console} from "./server/Console"; import {UpdaterModal} from "./UpdaterModal"; import {InstallUpdateVerify} from "../../wailsjs/go/installer/InstallerController"; import {SendRconCommand} from "../../wailsjs/go/helpers/HelpersController"; +import {Settings} from "./server/Settings"; type Props = { @@ -185,11 +186,13 @@ export const Server = ({id, className}: Props) => { Console - General + General Settings + {/*Server Settings*/} Administration + {/**/} CheckServerInstalled(serv.id).then((val) => setIsInstalled(val)).catch((reason) => console.error(reason))}/> ) : ( setIsInstalled(true)}/>)} diff --git a/frontend/src/pages/server/Administration.tsx b/frontend/src/pages/server/Administration.tsx index fea9db7..1ea1c3e 100644 --- a/frontend/src/pages/server/Administration.tsx +++ b/frontend/src/pages/server/Administration.tsx @@ -46,7 +46,6 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { - return ( @@ -135,7 +134,13 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) { - setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /> + setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /> + {/* setServ((p) => ({ ...p, restartOnServerQuit: e.target.checked }))} />*/} + + Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick -ForceAllowCaveFlyers) + setServ((p) => ({ ...p, extraDashArgs: e.target.value }))}> + Custom server "questionmark" arguments (only use args like: ?PreventSpawnAnimations=true?PreventTribeAlliances=true) + setServ((p) => ({ ...p, extraQuestionmarkArguments: e.target.value }))}> diff --git a/frontend/src/pages/server/Settings.tsx b/frontend/src/pages/server/Settings.tsx new file mode 100644 index 0000000..f7492f4 --- /dev/null +++ b/frontend/src/pages/server/Settings.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import {server} from "../../../wailsjs/go/models"; +import { + Button, + Card, Checkbox, + DialogActions, + DialogContent, + DialogTitle, + Divider, FormLabel, Input, + Modal, + ModalDialog, + TabPanel, + Typography +} from "@mui/joy"; +import {IconAlertCircleFilled} from "@tabler/icons-react"; + +type Props = { + setServ: React.Dispatch> + serv: server.Server; + +} + +export function Settings({setServ, serv}: Props) { + return ( + + + + Mods + + + + + + Mods (e.g.: modid1,modid2,modid3) + setServ((p) => ({ ...p, mods: e.target.value }))}> + + + + + ); +} \ No newline at end of file diff --git a/server/helpers.go b/server/helpers.go index 4336270..b0c780e 100644 --- a/server/helpers.go +++ b/server/helpers.go @@ -44,6 +44,12 @@ func generateNewDefaultServer(id int) Server { Id: id, DisableUpdateOnStart: false, + RestartOnServerQuit: true, + + ExtraQuestionmarkArguments: "", + ExtraDashArgs: "", + + Mods: "", ServerAlias: "Server " + strconv.Itoa(id), diff --git a/server/server.go b/server/server.go index 3d5698a..94b7614 100644 --- a/server/server.go +++ b/server/server.go @@ -6,7 +6,6 @@ import ( "github.com/keybase/go-ps" "github.com/wailsapp/wails/v2/pkg/runtime" "os/exec" - "path" "strconv" ) @@ -23,9 +22,15 @@ type Server struct { //PREFERENCES DisableUpdateOnStart bool `json:"disableUpdateOnStart"` + RestartOnServerQuit bool `json:"restartOnServerQuit"` //CONFIGURATION VARIABLES + ExtraDashArgs string `json:"extraDashArgs"` + ExtraQuestionmarkArguments string `json:"extraQuestionmarkArguments"` + + Mods string `json:"mods"` + // Id is the id of the server Id int `json:"id"` @@ -83,6 +88,19 @@ func (s *Server) Start() error { _ = s.Command.Wait() runtime.EventsEmit(s.ctx, "onServerExit", s.Id) + + /*//restart server on crash + if err != nil && s.RestartOnServerQuit { + code := s.Command.ProcessState.ExitCode() + time.Sleep(2 * time.Second) + if code != 0 { + err := s.Start() + if err != nil { + runtime.EventsEmit(s.ctx, "onRestartServerFailed", err) + } + } + }*/ + }() } @@ -152,7 +170,14 @@ func (s *Server) CreateArguments() string { basePrompt += "?QueryPort=" + strconv.Itoa(s.QueryPort) basePrompt += "?RCONEnabled=true?RCONServerGameLogBuffer=600?RCONPort=" + strconv.Itoa(s.RCONPort) basePrompt += "?MaxPlayers=" + strconv.Itoa(s.MaxPlayers) - basePrompt += "?ServerAdminPassword=" + s.AdminPassword + basePrompt += s.ExtraQuestionmarkArguments + //TODO move AdminPassword to ini + basePrompt += "?ServerAdminPassword=" + s.AdminPassword + "?" + + if s.Mods != "" { + basePrompt += " -mods=" + s.Mods + } + basePrompt += " " + s.ExtraDashArgs return basePrompt }