Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client sniperline and server stationary gun options #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/api/soldat/configs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface GraphicsConfig extends SoldatConfig {
ui_style: string;
r_scaleinterface: string;
ui_playerindicator: string;
ui_sniperline: string;
ui_killconsole: string;

r_swapeffect: string;
Expand Down Expand Up @@ -87,6 +88,7 @@ export interface ServerConfig extends SoldatConfig {
sv_bullettime: string;
sv_friendlyfire: string;
sv_sniperline: string;
sv_stationaryguns: string;

sv_survivalmode: string;
sv_survivalmode_clearweapons: string;
Expand Down Expand Up @@ -127,4 +129,4 @@ export interface ServerConfig extends SoldatConfig {

net_port: string;
};
}
}
11 changes: 8 additions & 3 deletions src/api/soldat/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ const start = (

// For now this seems to get the job done, even though a proper
// communication system might be better...
let stdoutOutput = "";
serverProcess.stdout.setEncoding("utf8");
serverProcess.stdout.on("data", (output: string) => {
if (output.includes("[NET] Game networking initialized.")) {
onReady();
if (!stdoutOutput.includes("[NET] Game networking initialized.")) {
stdoutOutput += output;

if (stdoutOutput.includes("[NET] Game networking initialized.")) {
onReady();
}
}
});

Expand Down Expand Up @@ -75,4 +80,4 @@ const stop = (): void => {
serverProcess = undefined;
}

export { start, stop };
export { start, stop };
22 changes: 20 additions & 2 deletions src/components/LocalGame/Gameplay/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const GameplayForm: React.FC<GameplayFormProps> = props => {
gameplay.sniperLine = checked;
break;

case "stationary-guns":
gameplay.stationaryGuns = checked;
break;

case "survival-destroy-weapons":
gameplay.styles.survivalDestroyWeaponsAfterRound = checked;
break;
Expand Down Expand Up @@ -244,7 +248,7 @@ const GameplayForm: React.FC<GameplayFormProps> = props => {

<div className="field">
<label className="label" htmlFor="sniper-line">
Sniper line
Allow sniper line
</label>
<div className="user-input">
<Checkbox
Expand All @@ -255,8 +259,22 @@ const GameplayForm: React.FC<GameplayFormProps> = props => {
onToggle={handleCheckboxToggle} />
</div>
</div>

<div className="field">
<label className="label" htmlFor="stationary-guns">
Stationary guns
</label>
<div className="user-input">
<Checkbox
colorTheme="dark"
id="stationary-guns"
name="stationary-guns"
checked={gameplay.stationaryGuns}
onToggle={handleCheckboxToggle} />
</div>
</div>
</div>
)
}

export default observer(GameplayForm);
export default observer(GameplayForm);
21 changes: 20 additions & 1 deletion src/components/Settings/GraphicsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const GraphicsPanel: React.FC<GraphicsPanelProps> = props => {
graphicsSettings.playerIndicator = checked;
}

const handleClientSniperlineToggle = (checked: boolean): void => {
graphicsSettings.clientSniperline = checked;
}

const handleKillsListToggle = (checked: boolean): void => {
graphicsSettings.killsList = checked;
}
Expand Down Expand Up @@ -333,6 +337,21 @@ const GraphicsPanel: React.FC<GraphicsPanelProps> = props => {
</div>
</div>

<div className="field">
<label
className="label"
htmlFor="client-sniperline">
Display sniperline (if server allows it)
</label>
<div className="user-input">
<Checkbox
id="client-sniperline"
colorTheme="dark"
checked={graphicsSettings.clientSniperline}
onToggle={handleClientSniperlineToggle} />
</div>
</div>

<div className="field">
<label
className="label"
Expand Down Expand Up @@ -406,4 +425,4 @@ const GraphicsPanel: React.FC<GraphicsPanelProps> = props => {
)
}

export default observer(GraphicsPanel);
export default observer(GraphicsPanel);
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ app.on("activate", () => {
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
// code. You can also put them in separate files and import them here.
7 changes: 6 additions & 1 deletion src/settings/client/graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface GraphicsSettingsData {
interfaceStyle: string;
scaleInterface: boolean;
playerIndicator: boolean;
clientSniperline: boolean;
killsList: boolean;

verticalSync: boolean;
Expand Down Expand Up @@ -63,6 +64,7 @@ const defaultGraphicsSettings: GraphicsSettingsData = {

interfaceStyle: "Default",
playerIndicator: true,
clientSniperline: false,
scaleInterface: true,
killsList: true,

Expand All @@ -88,6 +90,7 @@ class GraphicsSettings implements GraphicsSettingsData {
@observable interfaceStyle: string;
@observable scaleInterface: boolean;
@observable playerIndicator: boolean;
@observable clientSniperline: boolean;
@observable killsList: boolean;

@observable verticalSync: boolean;
Expand Down Expand Up @@ -120,6 +123,7 @@ class GraphicsSettings implements GraphicsSettingsData {
this.interfaceStyle = config?.cvars.ui_style;
this.scaleInterface = toBool(config?.cvars.r_scaleinterface);
this.playerIndicator = toBool(config?.cvars.ui_playerindicator);
this.clientSniperline = toBool(config?.cvars.ui_sniperline);
this.killsList = toBool(config?.cvars.ui_killconsole);

this.verticalSync = toBool(config?.cvars.r_swapeffect);
Expand Down Expand Up @@ -159,6 +163,7 @@ class GraphicsSettings implements GraphicsSettingsData {
ui_style: this.interfaceStyle,
r_scaleinterface: toString(this.scaleInterface),
ui_playerindicator: toString(this.playerIndicator),
ui_sniperline: toString(this.clientSniperline),
ui_killconsole: toString(this.killsList),

r_swapeffect: toString(this.verticalSync),
Expand All @@ -168,4 +173,4 @@ class GraphicsSettings implements GraphicsSettingsData {
}
}

export default GraphicsSettings;
export default GraphicsSettings;
8 changes: 6 additions & 2 deletions src/settings/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface GameplaySettings {
bulletTime: boolean;
friendlyFire: boolean;
sniperLine: boolean;
stationaryGuns: boolean;
}

export enum BonusFrequencies {
Expand Down Expand Up @@ -119,7 +120,8 @@ const defaultServerSettings: ServerSettingsData = {

bulletTime: false,
friendlyFire: false,
sniperLine: false
sniperLine: true,
stationaryGuns: true
},
bots: {
noTeam: 4,
Expand Down Expand Up @@ -179,6 +181,7 @@ class ServerSettings implements ServerSettingsData {
bulletTime: toBool(config?.cvars.sv_bullettime),
friendlyFire: toBool(config?.cvars.sv_friendlyfire),
sniperLine: toBool(config?.cvars.sv_sniperline),
stationaryGuns: toBool(config?.cvars.sv_stationaryguns),
};

this.bots = {
Expand Down Expand Up @@ -253,6 +256,7 @@ class ServerSettings implements ServerSettingsData {
sv_bullettime: toString(this.gameplay.bulletTime),
sv_friendlyfire: toString(this.gameplay.friendlyFire),
sv_sniperline: toString(this.gameplay.sniperLine),
sv_stationaryguns: toString(this.gameplay.stationaryGuns),

bots_random_alpha: toString(this.bots.alpha),
bots_random_bravo: toString(this.bots.bravo),
Expand Down Expand Up @@ -313,4 +317,4 @@ class ServerSettings implements ServerSettingsData {
}
}

export default ServerSettings;
export default ServerSettings;