Some menu tweaks (#397)

* add: debug goal menu and new node flags to the flag selection menu

* translate: russian: translated new lines

* update: bump the year
This commit is contained in:
Владислав Сухов 2023-01-22 19:12:03 +06:00 committed by GitHub
commit 2d2ca5fd22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 259 additions and 64 deletions

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//
@ -564,7 +564,7 @@ int BotControl::cmdNodeCache () {
// turn graph on
graph.setEditFlag (GraphEdit::On);
// if "neareset" or nothing passed delete neareset, else delete by index
// if "nearest" or nothing passed delete nearest, else delete by index
if (strValue (nearest).empty () || strValue (nearest) == "nearest") {
graph.cachePoint (kInvalidNodeIndex);
}
@ -595,9 +595,9 @@ int BotControl::cmdNodeClean () {
msg ("Done. Processed %d nodes. %d useless paths was cleared.", graph.length (), removed);
}
else if (strValue (option).empty () || strValue (option) == "nearest") {
int removed = graph.clearConnections (graph.getEditorNeareset ());
int removed = graph.clearConnections (graph.getEditorNearest ());
msg ("Done. Processed node %d. %d useless paths was cleared.", graph.getEditorNeareset (), removed);
msg ("Done. Processed node %d. %d useless paths was cleared.", graph.getEditorNearest (), removed);
}
else {
int index = intValue (option);
@ -625,7 +625,7 @@ int BotControl::cmdNodeSetRadius () {
int radiusIndex = kInvalidNodeIndex;
if (strValue (index).empty () || strValue (index) == "nearest") {
radiusIndex = graph.getEditorNeareset ();
radiusIndex = graph.getEditorNearest ();
}
else {
radiusIndex = intValue (index);
@ -1268,9 +1268,7 @@ int BotControl::menuGraphPage2 (int item) {
switch (item) {
case 1:
graph.showStats ();
showMenu (Menu::NodeMainPage2);
showMenu (Menu::NodeDebug);
break;
case 2:
@ -1395,8 +1393,52 @@ int BotControl::menuGraphType (int item) {
return BotCommandResult::Handled;
}
int BotControl::menuGraphDebug (int item) {
closeMenu (); // reset menu display
switch (item) {
case 1:
graph.setEditFlag (GraphEdit::On);
cv_debug_goal.set (graph.getEditorNearest ());
if (cv_debug_goal.int_ () != kInvalidNodeIndex) {
msg ("Debug goal is set to node %d.", cv_debug_goal.int_ ());
}
else {
msg ("Cannot find the node. Debug goal is disabled.");
}
showMenu (Menu::NodeDebug);
break;
case 2:
graph.setEditFlag (GraphEdit::On);
cv_debug_goal.set (graph.getFacingIndex ());
if (cv_debug_goal.int_ () != kInvalidNodeIndex) {
msg ("Debug goal is set to node %d.", cv_debug_goal.int_ ());
}
else {
msg ("Cannot find the node. Debug goal is disabled.");
}
showMenu (Menu::NodeDebug);
break;
case 3:
cv_debug_goal.set (kInvalidNodeIndex);
msg ("Debug goal is disabled.");
showMenu (Menu::NodeDebug);
break;
case 10:
closeMenu ();
break;
}
return BotCommandResult::Handled;
}
int BotControl::menuGraphFlag (int item) {
closeMenu (); // reset menu display
int nearest = graph.getEditorNearest ();
switch (item) {
case 1:
@ -1405,12 +1447,24 @@ int BotControl::menuGraphFlag (int item) {
break;
case 2:
graph.toggleFlags (NodeFlag::TerroristOnly);
if (graph[nearest].flags == NodeFlag::CTOnly) {
graph.toggleFlags (NodeFlag::CTOnly);
graph.toggleFlags (NodeFlag::TerroristOnly);
}
else {
graph.toggleFlags (NodeFlag::TerroristOnly);
}
showMenu (Menu::NodeFlag);
break;
case 3:
graph.toggleFlags (NodeFlag::CTOnly);
if (graph[nearest].flags == NodeFlag::TerroristOnly) {
graph.toggleFlags (NodeFlag::TerroristOnly);
graph.toggleFlags (NodeFlag::CTOnly);
}
else {
graph.toggleFlags (NodeFlag::CTOnly);
}
showMenu (Menu::NodeFlag);
break;
@ -1423,6 +1477,60 @@ int BotControl::menuGraphFlag (int item) {
graph.toggleFlags (NodeFlag::Sniper);
showMenu (Menu::NodeFlag);
break;
case 6:
graph.toggleFlags (NodeFlag::Goal);
showMenu (Menu::NodeFlag);
break;
case 7:
graph.toggleFlags (NodeFlag::Rescue);
showMenu (Menu::NodeFlag);
break;
case 8:
if (graph[nearest].flags != NodeFlag::Crouch) {
graph.toggleFlags (NodeFlag::Crouch);
graph[nearest].origin.z += -18.0f;
}
else {
graph.toggleFlags (NodeFlag::Crouch);
graph[nearest].origin.z += 18.0f;
}
showMenu (Menu::NodeFlag);
break;
case 9:
// if the node doesn't have a camp flag, set it and open the camp directions selection menu
if (graph[nearest].flags != NodeFlag::Camp) {
graph.toggleFlags (NodeFlag::Camp);
showMenu (Menu::CampDirections);
break;
}
// otherwise remove the flag, and don't show the camp directions selection menu
else {
graph.toggleFlags (NodeFlag::Camp);
showMenu (Menu::NodeFlag);
break;
}
}
return BotCommandResult::Handled;
}
int BotControl::menuCampDirections (int item) {
closeMenu (); // reset menu display
switch (item) {
case 1:
graph.add (NodeAddFlag::Camp);
showMenu (Menu::CampDirections);
break;
case 2:
graph.add (NodeAddFlag::CampEnd);
showMenu (Menu::CampDirections);
break;
}
return BotCommandResult::Handled;
}
@ -2140,7 +2248,7 @@ void BotControl::createMenus () {
m_menus.emplace (
Menu::NodeMainPage2, keys (9),
"\\yWaypoint Operations (Page 2)\\w\n\n"
"1. Waypoint stats\n"
"1. Debug goal\n"
"2. Autowaypoint on/off\n"
"3. Set flags\n"
"4. Save waypoints\n"
@ -2183,18 +2291,41 @@ void BotControl::createMenus () {
"\\w9. Jump\n\n"
"0. Exit",
&BotControl::menuGraphType);
// debug goal menu
m_menus.emplace (
Menu::NodeDebug, keys (3),
"\\yDebug goal\\w\n\n"
"1. Debug nearest node\n"
"2. Debug facing node\n"
"3. Stop debugging\n\n"
"0. Exit",
&BotControl::menuGraphDebug);
// set waypoint flag menu
m_menus.emplace (
Menu::NodeFlag, keys (5),
Menu::NodeFlag, keys (9),
"\\yToggle Waypoint Flags\\w\n\n"
"1. Block with Hostage\n"
"2. Terrorists Specific\n"
"3. CTs Specific\n"
"4. Use Elevator\n"
"5. Sniper Point (\\yFor Camp Points Only!\\w)\n\n"
"5. Sniper Point (\\yFor Camp Points Only!\\w)\n"
"6. Map Goal\n"
"7. Rescue Zone\n"
"8. Crouch Down\n"
"9. Camp Point\n\n"
"0. Exit",
&BotControl::menuGraphFlag);
// set camp directions menu
m_menus.emplace (
Menu::CampDirections, keys (2),
"\\ySet Camp Point directions\\w\n\n"
"1. Camp Start\n"
"2. Camp End\n\n"
"0. Exit",
&BotControl::menuCampDirections);
// auto-path max distance
m_menus.emplace (

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//
@ -483,7 +483,7 @@ int BotGraph::getNearestNoBuckets (const Vector &origin, float minDistance, int
return index;
}
int BotGraph::getEditorNeareset () {
int BotGraph::getEditorNearest () {
if (!hasEditFlag (GraphEdit::On)) {
return kInvalidNodeIndex;
}
@ -564,7 +564,7 @@ void BotGraph::add (int type, const Vector &pos) {
switch (type) {
case NodeAddFlag::Camp:
index = getEditorNeareset ();
index = getEditorNearest ();
if (index != kInvalidNodeIndex) {
path = &m_paths[index];
@ -580,7 +580,7 @@ void BotGraph::add (int type, const Vector &pos) {
break;
case NodeAddFlag::CampEnd:
index = getEditorNeareset ();
index = getEditorNearest ();
if (index != kInvalidNodeIndex) {
path = &m_paths[index];
@ -597,7 +597,7 @@ void BotGraph::add (int type, const Vector &pos) {
return;
case NodeAddFlag::JumpStart:
index = getEditorNeareset ();
index = getEditorNearest ();
if (index != kInvalidNodeIndex && m_paths[index].number >= 0) {
float distance = m_editor->v.origin.distance (m_paths[index].origin);
@ -615,7 +615,7 @@ void BotGraph::add (int type, const Vector &pos) {
break;
case NodeAddFlag::JumpEnd:
index = getEditorNeareset ();
index = getEditorNearest ();
if (index != kInvalidNodeIndex && m_paths[index].number >= 0) {
float distance = m_editor->v.origin.distance (m_paths[index].origin);
@ -639,7 +639,7 @@ void BotGraph::add (int type, const Vector &pos) {
}
if (addNewNode) {
auto nearest = getEditorNeareset ();
auto nearest = getEditorNearest ();
// do not allow to place waypoints "inside" waypoints, make at leat 10 units range
if (exists (nearest) && newOrigin.distanceSq (m_paths[nearest].origin) < cr::square (10.0f)) {
@ -837,7 +837,7 @@ void BotGraph::erase (int target) {
if (bots.hasBotsOnline ()) {
bots.kickEveryone (true);
}
const int index = (target == kInvalidNodeIndex) ? getEditorNeareset () : target;
const int index = (target == kInvalidNodeIndex) ? getEditorNearest () : target;
if (!exists (index)) {
return;
@ -878,7 +878,7 @@ void BotGraph::erase (int target) {
void BotGraph::toggleFlags (int toggleFlag) {
// this function allow manually changing flags
int index = getEditorNeareset ();
int index = getEditorNearest ();
if (index != kInvalidNodeIndex) {
if (m_paths[index].flags & toggleFlag) {
@ -900,7 +900,7 @@ void BotGraph::toggleFlags (int toggleFlag) {
void BotGraph::setRadius (int index, float radius) {
// this function allow manually setting the zone radius
int node = exists (index) ? index : getEditorNeareset ();
int node = exists (index) ? index : getEditorNearest ();
if (node != kInvalidNodeIndex) {
m_paths[node].radius = static_cast <float> (radius);
@ -930,7 +930,7 @@ int BotGraph::getFacingIndex () {
// find the waypoint the user is pointing at
Twin <int32, float> result { kInvalidNodeIndex, 5.32f };
auto nearestNode = getEditorNeareset ();
auto nearestNode = getEditorNearest ();
// check bounds from eyes of editor
const auto &editorEyes = m_editor->v.origin + m_editor->v.view_ofs;
@ -974,7 +974,7 @@ int BotGraph::getFacingIndex () {
void BotGraph::pathCreate (char dir) {
// this function allow player to manually create a path from one node to another
int nodeFrom = getEditorNeareset ();
int nodeFrom = getEditorNearest ();
if (nodeFrom == kInvalidNodeIndex) {
ctrl.msg ("Unable to find nearest node in 50 units.");
@ -1017,7 +1017,7 @@ void BotGraph::pathCreate (char dir) {
void BotGraph::erasePath () {
// this function allow player to manually remove a path from one node to another
int nodeFrom = getEditorNeareset ();
int nodeFrom = getEditorNearest ();
if (nodeFrom == kInvalidNodeIndex) {
ctrl.msg ("Unable to find nearest node in 50 units.");
@ -1067,7 +1067,7 @@ void BotGraph::erasePath () {
}
void BotGraph::cachePoint (int index) {
int node = exists (index) ? index : getEditorNeareset ();
int node = exists (index) ? index : getEditorNearest ();
if (node == kInvalidNodeIndex) {
m_cacheNodeIndex = kInvalidNodeIndex;

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//

View file

@ -1,6 +1,6 @@
//
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
// Copyright © 2004-2022 YaPB Project <yapb@jeefo.net>.
// Copyright © 2004-2023 YaPB Project <yapb@jeefo.net>.
//
// SPDX-License-Identifier: MIT
//