MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / ResolutionCommand_Execute

Function ResolutionCommand_Execute

src/Commands.c:213–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211};
212
213static void ResolutionCommand_Execute(const cc_string* args, int argsCount) {
214 int width, height;
215 if (argsCount < 2) {
216 Chat_Add4("&e/client: &fCurrent resolution is %i@%f2 x %i@%f2",
217 &Window_Main.Width, &DisplayInfo.ScaleX, &Window_Main.Height, &DisplayInfo.ScaleY);
218 } else if (!Convert_ParseInt(&args[0], &width) || !Convert_ParseInt(&args[1], &height)) {
219 Chat_AddRaw("&e/client: &cWidth and height must be integers.");
220 } else if (width <= 0 || height <= 0) {
221 Chat_AddRaw("&e/client: &cWidth and height must be above 0.");
222 } else {
223 Window_SetSize(width, height);
224 /* Window_Create uses these, but scales by DPI. Hence DPI unscale them here. */
225 Options_SetInt(OPT_WINDOW_WIDTH, (int)(width / DisplayInfo.ScaleX));
226 Options_SetInt(OPT_WINDOW_HEIGHT, (int)(height / DisplayInfo.ScaleY));
227 }
228}
229
230static struct ChatCommand ResolutionCommand = {
231 "Resolution", ResolutionCommand_Execute,

Callers

nothing calls this directly

Calls 5

Chat_Add4Function · 0.85
Convert_ParseIntFunction · 0.85
Chat_AddRawFunction · 0.85
Options_SetIntFunction · 0.85
Window_SetSizeFunction · 0.70

Tested by

no test coverage detected