From: RĂ©mi Verschelde Date: Sat, 11 Feb 2017 14:28:38 +0000 (+0100) Subject: Devtools: Add clotheslist cmd and fix devkeys in console X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=aff8402e75951f0407020e7fa7c69f831c141ba1 Devtools: Add clotheslist cmd and fix devkeys in console The `clotheslist` and `clotheslistnear` can be used to list the clothes (and their tint) of a player in the terminal. The other fix prevents text input in the console from activating devtools hotkeys (e.g. "p" placing a player). --- diff --git a/Docs/DEVTOOLS.txt b/Docs/DEVTOOLS.txt index db82aac..10d040c 100644 --- a/Docs/DEVTOOLS.txt +++ b/Docs/DEVTOOLS.txt @@ -160,6 +160,8 @@ clothes (string) - adds clothes to your character. folder of type ".png". You may add any png file in that folder and use it with the clothes command. See Decal Editing to create such files. clothesnear - does the same for the character nearest to you. +clotheslist - lists the clothes of the main player (and their tint). +clotheslistnear - does the same for the character nearest to you. Skybox ~~~~~~ diff --git a/Source/Devtools/ConsoleCmds.cpp b/Source/Devtools/ConsoleCmds.cpp index f6e9dc8..10f37e8 100644 --- a/Source/Devtools/ConsoleCmds.cpp +++ b/Source/Devtools/ConsoleCmds.cpp @@ -160,6 +160,18 @@ static void set_clothes(int pnum, const char* args) Person::players[pnum]->DoMipmaps(); } +static void list_clothes(int pnum) +{ + printf("Clothes from player %d:\n", pnum); + for (int i = 0; i < Person::players[pnum]->numclothes; i++) { + printf("%s (%f %f %f)\n", + Person::players[pnum]->clothes[i], + Person::players[pnum]->clothestintr[i], + Person::players[pnum]->clothestintg[i], + Person::players[pnum]->clothestintb[i]); + } +} + /* Console commands themselves */ void ch_quit(const char*) @@ -438,6 +450,19 @@ void ch_clothesnear(const char* args) } } +void ch_clotheslist(const char*) +{ + list_clothes(0); +} + +void ch_clotheslistnear(const char*) +{ + int closest = findClosestPlayer(); + if (closest >= 0) { + list_clothes(closest); + } +} + void ch_belt(const char*) { Person::players[0]->skeleton.clothes = !Person::players[0]->skeleton.clothes; diff --git a/Source/Devtools/ConsoleCmds.def b/Source/Devtools/ConsoleCmds.def index 162636e..eb90dde 100644 --- a/Source/Devtools/ConsoleCmds.def +++ b/Source/Devtools/ConsoleCmds.def @@ -42,6 +42,8 @@ DECLARE_COMMAND(armornear) DECLARE_COMMAND(metal) DECLARE_COMMAND(clothes) DECLARE_COMMAND(clothesnear) +DECLARE_COMMAND(clotheslist) +DECLARE_COMMAND(clotheslistnear) DECLARE_COMMAND(noclothes) DECLARE_COMMAND(noclothesnear) DECLARE_COMMAND(belt) diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index c1b0386..0b83ced 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1022,18 +1022,6 @@ void Game::ProcessInput() printf("Stereo separation increased to %f\n", stereoseparation); } - /* Devtools */ - if (devtools && !mainmenu) { - ProcessDevInput(); - } -} - -void Game::ProcessDevInput() -{ - if (!devtools || mainmenu) { - return; - } - /* Console */ if (Input::isKeyPressed(consolekey)) { console = !console; @@ -1045,6 +1033,18 @@ void Game::ProcessDevInput() } } + /* Devtools */ + if (devtools && !mainmenu && !console) { + ProcessDevInput(); + } +} + +void Game::ProcessDevInput() +{ + if (!devtools || mainmenu || console) { + return; + } + if (Input::isKeyDown(SDL_SCANCODE_LALT)) { /* Enable editor */ if (Input::isKeyPressed(SDL_SCANCODE_M) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {