Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Add custom arguments and Disable update on start button #71

Merged
merged 5 commits into from
Nov 3, 2023
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
5 changes: 4 additions & 1 deletion frontend/src/pages/Server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -185,11 +186,13 @@ export const Server = ({id, className}: Props) => {
</div>
<TabList className={'w-full'}>
<Tab variant="plain" indicatorInset color="neutral">Console</Tab>
<Tab variant="plain" indicatorInset color="neutral">General</Tab>
<Tab variant="plain" indicatorInset color="neutral">General Settings</Tab>
{/*<Tab variant="plain" indicatorInset color="neutral">Server Settings</Tab>*/}
<Tab variant="plain" indicatorInset color="neutral">Administration</Tab>
</TabList>
<Console serv={serv} setServ={setServ} serverStatus={serverStatus}/>
<General serv={serv} setServ={setServ}/>
{/*<Settings setServ={setServ} serv={serv}></Settings>*/}
<Administration serv={serv} setServ={setServ} onServerFilesDeleted={() => CheckServerInstalled(serv.id).then((val) => setIsInstalled(val)).catch((reason) => console.error(reason))}/>
</Tabs>) : (<InstallUpdater serv={serv} setServ={setServ} onInstalled={() => setIsInstalled(true)}/>)}
</Card>
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/pages/server/Administration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {




return (
<TabPanel value={2} className={'space-y-8'}>
<Card variant="soft" className={''}>
Expand Down Expand Up @@ -135,7 +134,13 @@ export function Administration({setServ, serv, onServerFilesDeleted}: Props) {

<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<Checkbox label="Disable update on server start" checked={serv?.disableUpdateOnStart} onChange={(e) => setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} />
<Checkbox label="Disable update on server start" checked={serv?.disableUpdateOnStart} onChange={(e) => setServ((p) => ({ ...p, disableUpdateOnStart: e.target.checked }))} /><br/>
{/*<Checkbox label="Restart server on server quit" checked={serv?.restartOnServerQuit} onChange={(e) => setServ((p) => ({ ...p, restartOnServerQuit: e.target.checked }))} />*/}

<FormLabel>Custom server "dash" arguments (only use args like: -EnableIdlePlayerKick -ForceAllowCaveFlyers)</FormLabel>
<Input value={serv?.extraDashArgs} onChange={(e) => setServ((p) => ({ ...p, extraDashArgs: e.target.value }))}></Input>
<FormLabel>Custom server "questionmark" arguments (only use args like: ?PreventSpawnAnimations=true?PreventTribeAlliances=true)</FormLabel>
<Input value={serv?.extraQuestionmarkArguments} onChange={(e) => setServ((p) => ({ ...p, extraQuestionmarkArguments: e.target.value }))}></Input>
</div>
</div>
</Card>
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/pages/server/Settings.tsx
Original file line number Diff line number Diff line change
@@ -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<React.SetStateAction<server.Server>>
serv: server.Server;

}

export function Settings({setServ, serv}: Props) {
return (
<TabPanel value={2} className={'space-y-8'}>
<Card variant="soft" className={''}>
<Typography level="title-md">
Mods
</Typography>
<Divider className={'mx-2'}/>

<div className={'space-x-4 w-full flex'}>
<div className={'inline-block'}>
<FormLabel>Mods (e.g.: modid1,modid2,modid3)</FormLabel>
<Input className={"w-[60vw]"} value={serv?.mods} onChange={(e) => setServ((p) => ({ ...p, mods: e.target.value }))}></Input>
</div>
</div>
</Card>
</TabPanel>
);
}
6 changes: 6 additions & 0 deletions server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ func generateNewDefaultServer(id int) Server {
Id: id,

DisableUpdateOnStart: false,
RestartOnServerQuit: true,

ExtraQuestionmarkArguments: "",
ExtraDashArgs: "",

Mods: "",

ServerAlias: "Server " + strconv.Itoa(id),

Expand Down
29 changes: 27 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/keybase/go-ps"
"github.com/wailsapp/wails/v2/pkg/runtime"
"os/exec"

"path"
"strconv"
)
Expand All @@ -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"`

Expand Down Expand Up @@ -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)
}
}
}*/

}()
}

Expand Down Expand Up @@ -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
}
Loading