From ea88dde4be225d19c12bea4a581aa21f17237070 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 21 Oct 2020 18:51:57 +0200 Subject: Added Strip, AutoRefill, indexing for InventoryActions and Wield Index starts at 1 now --- builtin/client/chatcommands.lua | 2 +- builtin/client/cheats/combat.lua | 6 ++--- builtin/client/cheats/init.lua | 2 ++ builtin/client/cheats/inventory.lua | 48 ++++++++++++++++++++++++++++++------- builtin/client/util.lua | 6 ++--- builtin/settingtypes.txt | 8 +++++++ 6 files changed, 57 insertions(+), 15 deletions(-) (limited to 'builtin') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 7c3dd521e..8090b2bef 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -155,7 +155,7 @@ core.register_chatcommand("place", { func = function(param) local success, pos = core.parse_relative_pos(param) if success then - cores.place_node(pos) + core.place_node(pos) return true, "Node placed at " .. core.pos_to_string(pos) end return false, pos diff --git a/builtin/client/cheats/combat.lua b/builtin/client/cheats/combat.lua index b497c6c1b..1f9ba9a91 100644 --- a/builtin/client/cheats/combat.lua +++ b/builtin/client/cheats/combat.lua @@ -2,7 +2,7 @@ local placed_crystal local switched_to_totem = 0 local used_sneak = true local totem_move_action = InventoryAction("move") -totem_move_action:to("current_player", "main", 8) +totem_move_action:to("current_player", "main", 9) core.register_globalstep(function(dtime) local player = core.localplayer @@ -48,9 +48,9 @@ core.register_globalstep(function(dtime) if totem_stack and totem_stack:get_name() ~= "mobs_mc:totem" then local totem_index = core.find_item("mobs_mc:totem") if totem_index then - totem_move_action:from("current_player", "main", totem_index - 1) + totem_move_action:from("current_player", "main", totem_index) totem_move_action:apply() - player:set_wield_index(8) + player:set_wield_index(9) end end end diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index a7be83cee..c579f2b89 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -62,6 +62,8 @@ core.cheats = { ["Enderchest"] = function() core.open_enderchest() end, ["HandSlot"] = function() core.open_handslot() end, ["NextItem"] = "next_item", + ["Strip"] = "strip", + ["AutoRefill"] = "autorefill", } } diff --git a/builtin/client/cheats/inventory.lua b/builtin/client/cheats/inventory.lua index faa7d1c0e..b9943f507 100644 --- a/builtin/client/cheats/inventory.lua +++ b/builtin/client/cheats/inventory.lua @@ -2,15 +2,48 @@ local elapsed_time = 0 local tick_time = 0.05 local drop_action = InventoryAction("drop") +local strip_move_act = InventoryAction("move") +strip_move_act:to("current_player", "craft", 1) +local strip_craft_act = InventoryAction("craft") +strip_craft_act:craft("current_player") +local strip_move_back_act = InventoryAction("move") +strip_move_back_act:from("current_player", "craftresult", 1) + core.register_globalstep(function(dtime) + local player = core.localplayer + if not player then return end + local item = player:get_wielded_item() + local itemdef = core.get_item_def(item:get_name()) + local wieldindex = player:get_wield_index() + -- AutoRefill + if core.settings:get_bool("autorefill") and itemdef then + local space = item:get_free_space() + local i = core.find_item(item:get_name(), wieldindex + 1) + if i and space > 0 then + local move_act = InventoryAction("move") + move_act:to("current_player", "main", wieldindex) + move_act:from("current_player", "main", i) + move_act:set_count(space) + move_act:apply() + end + end + -- Strip + if core.settings:get_bool("strip") then + if itemdef and itemdef.groups.tree and player:get_control().RMB then + strip_move_act:from("current_player", "main", wieldindex) + strip_move_back_act:to("current_player", "main", wieldindex) + strip_move_act:apply() + strip_craft_act:apply() + strip_move_back_act:apply() + end + end -- AutoEject if core.settings:get_bool("autoeject") then - local player = core.localplayer local list = (core.settings:get("eject_items") or ""):split(",") local inventory = core.get_inventory("current_player") for index, stack in pairs(inventory.main) do if table.indexof(list, stack:get_name()) ~= -1 then - drop_action:from("current_player", "main", index - 1) + drop_action:from("current_player", "main", index) drop_action:apply() end end @@ -19,12 +52,8 @@ core.register_globalstep(function(dtime) if core.settings:get_bool("next_item") then elapsed_time = elapsed_time + dtime if elapsed_time < tick_time then return end - local player = minetest.localplayer - if not player then return end - local item = player:get_wielded_item() if item:get_count() == 0 then - local index = player:get_wield_index() - player:set_wield_index(index + 1) + player:set_wield_index(wieldindex + 1) end elapsed_time = 0 end @@ -62,7 +91,7 @@ core.register_on_punchnode(function(pos, node) for index, stack in pairs(inventory.main) do is_better, best_time = check_tool(stack, node_groups, best_time) if is_better then - new_index = index - 1 + new_index = index end end player:set_wield_index(new_index) @@ -113,3 +142,6 @@ local hand_formspec = "size[9,8.75]".. function core.open_handslot() minetest.show_formspec("__builtin__:hand", hand_formspec) end + + + diff --git a/builtin/client/util.lua b/builtin/client/util.lua index d61b547c6..20e0e1d1b 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -21,9 +21,9 @@ function core.parse_relative_pos(param) return success, pos end -function core.find_item(item) +function core.find_item(item, mini, maxi) for index, stack in ipairs(core.get_inventory("current_player").main) do - if stack:get_name() == item then + if (not mini or index >= mini) and (not maxi or index <= maxi) and stack:get_name() == item then return index end end @@ -32,7 +32,7 @@ end function core.switch_to_item(item) local i = core.find_item(item) if i then - core.localplayer:set_wield_index(i - 1) + core.localplayer:set_wield_index(i) return true else return false diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f30a16789..a7a92291d 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2298,3 +2298,11 @@ autotnt (PlaceOnTop) bool false replace (Replace) bool false crystal_pvp (CrystalPvP) bool false + +autototem (AutoTotem) bool false + +dont_point_nodes (ThroughWalls) bool false + +strip (Strip) bool false + +autorefill (AutoRefill) bool false -- cgit v1.2.3 From b29d6bc196b3a6bafa1b200e8944cf277b0bc9c1 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Wed, 21 Oct 2020 17:49:17 -0700 Subject: Make cheat menu color and font configurable via settings --- builtin/settingtypes.txt | 25 +++++++++++++++++++++++++ src/defaultsettings.cpp | 7 +++++++ src/gui/cheatMenu.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/gui/cheatMenu.h | 3 +++ 4 files changed, 79 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f30a16789..ebd0ad621 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2298,3 +2298,28 @@ autotnt (PlaceOnTop) bool false replace (Replace) bool false crystal_pvp (CrystalPvP) bool false + +[Cheat Menu] + +# Font to use for cheat menu +cheat_menu_font (MenuFont) enum FM_Standard, FM_Mono, FM_Fallback, FM_Simple, FM_SimpleMono, FM_MaxMode, FM_Unspecified + +# (RGB value) +m_bg_color (Cell background color) v3f 45 45 68 + +m_bg_color_alpha (Cell background color alpha) int 173 + +# (RGB value) +m_active_bg_color (Active cell background color) v3f 0 0 0 + +m_active_bg_color_alpha (Active cell background color alpha) int 210 + +# (RGB value) +m_font_color (Font color) v3f 255 255 255 + +m_font_color_alpha (Font color alpha) int 195 + +# (RGB value) +m_selected_font_color (Selected font color) v3f 255 255 255 + +m_selected_font_color_alpha (Selected font color alpha) int 235 \ No newline at end of file diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2899f2509..525f94678 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -63,6 +63,13 @@ void set_default_settings(Settings *settings) settings->setDefault("max_out_chat_queue_size", "20"); settings->setDefault("pause_on_lost_focus", "false"); settings->setDefault("enable_register_confirmation", "true"); + + // Cheat Menu + settings->setDefault("cheat_menu_font", "FM_Mono"); + settings->setDefault("m_bg_color_alpha", "173"); + settings->setDefault("m_active_bg_color_alpha", "210"); + settings->setDefault("m_font_color_alpha", "195"); + settings->setDefault("m_selected_font_color_alpha", "235"); // Cheats settings->setDefault("xray", "false"); diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 548ddea73..7839caaad 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -18,11 +18,54 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "script/scripting_client.h" #include "client/client.h" #include "client/fontengine.h" +#include "settings.h" #include +FontMode fontStringToEnum(std::string str) { + if (str == "FM_Standard") + return FM_Standard; + else if (str == "FM_Mono") + return FM_Mono; + else if (str == "FM_Fallback") + return FM_Fallback; + else if (str == "FM_Simple") + return FM_Simple; + else if (str == "FM_SimpleMono") + return FM_SimpleMono; + else if (str == "FM_MaxMode") + return FM_MaxMode; + else if (str == "FM_Unspecified") + return FM_Unspecified; + else + return FM_Standard; +} + CheatMenu::CheatMenu(Client *client) : m_client(client) { - m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); + FontMode fontMode = fontStringToEnum(g_settings->get("cheat_menu_font")); + irr::core::vector3df bg_color; + irr::core::vector3df active_bg_color; + irr::core::vector3df font_color; + irr::core::vector3df selected_font_color; + + g_settings->getV3FNoEx("m_bg_color", bg_color); + g_settings->getV3FNoEx("m_active_bg_color", active_bg_color); + g_settings->getV3FNoEx("m_font_color", font_color); + g_settings->getV3FNoEx("m_selected_font_color", selected_font_color); + + m_bg_color = video::SColor(g_settings->getU32("m_bg_color_alpha"), + bg_color.X, bg_color.Y, bg_color.Z); + + m_active_bg_color = video::SColor(g_settings->getU32("m_active_bg_color_alpha"), + active_bg_color.X, active_bg_color.Y, active_bg_color.Z); + + m_font_color = video::SColor(g_settings->getU32("m_font_color_alpha"), + font_color.X, font_color.Y, font_color.Z); + + m_selected_font_color = video::SColor(g_settings->getU32("m_selected_font_color_alpha"), + selected_font_color.X, selected_font_color.Y, selected_font_color.Z); + + m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, fontMode); if (!m_font) { errorstream << "CheatMenu: Unable to load fallback font" << std::endl; diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 4ffaa177d..350bf9ac3 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irrlichttypes_extrabloated.h" +#include "settings.h" #include #include @@ -67,6 +68,8 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); + FontMode fontStringToEnum(std::string str); + Client *m_client; gui::IGUIFont *m_font = nullptr; -- cgit v1.2.3 From 8bc7d49b32afb215d262d8282988adf9e836396c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 22 Oct 2020 20:05:18 +0200 Subject: Added Nuke --- builtin/client/cheats/init.lua | 1 + builtin/client/cheats/world.lua | 17 +++++++++++++++++ builtin/settingtypes.txt | 2 ++ src/defaultsettings.cpp | 1 + 4 files changed, 21 insertions(+) (limited to 'builtin') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index c579f2b89..8d634a766 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -38,6 +38,7 @@ core.cheats = { ["BlockWater"] = "block_water", ["PlaceOnTop"] = "autotnt", ["Replace"] = "replace" + ["Nuke"] = "nuke" }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", diff --git a/builtin/client/cheats/world.lua b/builtin/client/cheats/world.lua index 5b97b206b..6cbdd67fc 100644 --- a/builtin/client/cheats/world.lua +++ b/builtin/client/cheats/world.lua @@ -48,6 +48,23 @@ core.register_globalstep(function(dtime) end end end + if core.settings:get_bool("nuke") then + local i = 0 + for x = pos.x - 5, pos.x + 5 do + for y = pos.y - 5, pos.y + 5 do + for z = pos.z - 5, pos.z + 5 do + local p = vector.new(x, y, z) + local node = core.get_node_or_nil(p) + local def = node and core.get_node_def(node.name) + if def and def.diggable then + if i > nodes_per_tick then return end + core.dig_node(p) + i = i + 1 + end + end + end + end + end end) diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index a7a92291d..15c62ead1 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2306,3 +2306,5 @@ dont_point_nodes (ThroughWalls) bool false strip (Strip) bool false autorefill (AutoRefill) bool false + +nuke (Nuke) bool false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 6cc28ac32..bde6505a0 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -113,6 +113,7 @@ void set_default_settings(Settings *settings) settings->setDefault("dont_point_nodes", "false"); settings->setDefault("strip", "false"); settings->setDefault("autorefill", "false"); + settings->setDefault("nuke", "false"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3 From 6652d7ac2a463581aa53c1599b7b93762422ff0f Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Thu, 22 Oct 2020 17:36:31 -0700 Subject: Add Block Formspec Hack --- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 2 ++ src/defaultsettings.cpp | 1 + src/gui/cheatMenu.h | 2 +- src/network/clientpackethandler.cpp | 4 ++++ 5 files changed, 9 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index a7be83cee..5e94ed86c 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -51,6 +51,7 @@ core.cheats = { ["PointLiquids"] = "point_liquids", ["PrivBypass"] = "priv_bypass", ["AutoRespawn"] = "autorespawn", + ["BlockFormspec"] = "block_formspec" }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ebd0ad621..f13492146 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2299,6 +2299,8 @@ replace (Replace) bool false crystal_pvp (CrystalPvP) bool false +block_formspec (BlockFormSpec) bool false + [Cheat Menu] # Font to use for cheat menu diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 525f94678..6a37ebab9 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -118,6 +118,7 @@ void set_default_settings(Settings *settings) settings->setDefault("crystal_pvp", "false"); settings->setDefault("autototem", "false"); settings->setDefault("dont_point_nodes", "false"); + settings->setDefault("block_formspec", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index c25af5ed2..513d217b6 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -72,7 +72,7 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); - FontMode fontStringToEnum(std::string str); + FontMode fontStringToEnum(std::string str) Client *m_client; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index f0fb09fad..f3c2bc134 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -957,6 +957,10 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt) void Client::handleCommand_ShowFormSpec(NetworkPacket* pkt) { + if (g_settings->getBool("block_formspec")) { + return; + } + std::string formspec = pkt->readLongString(); std::string formname; -- cgit v1.2.3 From 8e9e76a5076db0042773c6b925698f018a208b29 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Fri, 23 Oct 2020 08:34:58 -0700 Subject: Revert "Add Block Formspec Hack" This reverts commit 6652d7ac2a463581aa53c1599b7b93762422ff0f. --- builtin/client/cheats/init.lua | 1 - builtin/settingtypes.txt | 2 -- src/defaultsettings.cpp | 1 - src/gui/cheatMenu.h | 2 +- src/network/clientpackethandler.cpp | 4 ---- 5 files changed, 1 insertion(+), 9 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 5e94ed86c..a7be83cee 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -51,7 +51,6 @@ core.cheats = { ["PointLiquids"] = "point_liquids", ["PrivBypass"] = "priv_bypass", ["AutoRespawn"] = "autorespawn", - ["BlockFormspec"] = "block_formspec" }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f13492146..ebd0ad621 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2299,8 +2299,6 @@ replace (Replace) bool false crystal_pvp (CrystalPvP) bool false -block_formspec (BlockFormSpec) bool false - [Cheat Menu] # Font to use for cheat menu diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 6a37ebab9..525f94678 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -118,7 +118,6 @@ void set_default_settings(Settings *settings) settings->setDefault("crystal_pvp", "false"); settings->setDefault("autototem", "false"); settings->setDefault("dont_point_nodes", "false"); - settings->setDefault("block_formspec", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 513d217b6..c25af5ed2 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -72,7 +72,7 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); - FontMode fontStringToEnum(std::string str) + FontMode fontStringToEnum(std::string str); Client *m_client; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index f3c2bc134..f0fb09fad 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -957,10 +957,6 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt) void Client::handleCommand_ShowFormSpec(NetworkPacket* pkt) { - if (g_settings->getBool("block_formspec")) { - return; - } - std::string formspec = pkt->readLongString(); std::string formname; -- cgit v1.2.3 From 7cbe42b1dd0051a0c8a516700c2ef63f1ec090fc Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 11:57:16 +0100 Subject: Re-Added Chat Effects --- builtin/client/cheats/chat.lua | 35 +++++++++++++++++++++++++++++++++++ builtin/client/cheats/init.lua | 8 +++++--- builtin/client/util.lua | 9 +++++++-- builtin/settingtypes.txt | 6 ++++++ src/defaultsettings.cpp | 3 +++ 5 files changed, 56 insertions(+), 5 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 1b8094768..1f3ecbaa2 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -6,3 +6,38 @@ core.register_on_receiving_chat_message(function(message) return true end end) + +function core.send_colorized(message) + local starts_with = message:sub(1, 1) + + if starts_with == "/" or starts_with == "." then return end + + local reverse = core.settings:get_bool("chat_reverse") + + if reverse then + local msg = "" + for i = 1, #message do + msg = message:sub(i, i) .. msg + end + message = msg + end + + local use_chat_color = core.settings:get("use_chat_color") + local color = core.settings:get("chat_color") + + if color then + local msg + if color == "rainbow" then + msg = core.rainbow(message) + else + msg = core.colorize(color, message) + end + message = msg + end + + core.send_chat_message(message) + return true +end + +core.register_on_sending_chat_message(core.send_colorized) + diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 8d634a766..6fd78b8b8 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -37,8 +37,8 @@ core.cheats = { ["ScaffoldPlus"] = "scaffold_plus", ["BlockWater"] = "block_water", ["PlaceOnTop"] = "autotnt", - ["Replace"] = "replace" - ["Nuke"] = "nuke" + ["Replace"] = "replace", + ["Nuke"] = "nuke", }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", @@ -55,7 +55,9 @@ core.cheats = { }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", - ["Deathmessages"] = "mark_deathmessages" + ["Deathmessages"] = "mark_deathmessages", + ["ColoredChat"] = "use_chat_color", + ["ReversedChat"] = "chat_reverse", }, ["Inventory"] = { ["AutoEject"] = "autoeject", diff --git a/builtin/client/util.lua b/builtin/client/util.lua index 20e0e1d1b..783d0ceb1 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -42,6 +42,11 @@ end function core.get_pointed_thing() local pos = core.camera:get_pos() local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 5)) - local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or core.get_item_def(core.localplayer:get_wielded_item():get_name()).liquids_pointable) - return ray:next() + local player = core.localplayer + if not player then return end + local item = player:get_wielded_item() + if not item then return end + local def = core.get_item_def(item:get_name()) + local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or def and def.liquids_pointable) + return ray and ray:next() end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 15c62ead1..4dcfd1092 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2308,3 +2308,9 @@ strip (Strip) bool false autorefill (AutoRefill) bool false nuke (Nuke) bool false + +chat_color (Chat Color) string rainbow + +use_chat_color (ColoredChat) bool false + +chat_reverse (ReversedChat) bool false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bde6505a0..e3332b14f 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -114,6 +114,9 @@ void set_default_settings(Settings *settings) settings->setDefault("strip", "false"); settings->setDefault("autorefill", "false"); settings->setDefault("nuke", "false"); + settings->setDefault("chat_color", "rainbow"); + settings->setDefault("use_chat_color", "false"); + settings->setDefault("chat_reverse", "false"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3 From 00d51fbd56743a4ee091d2956a70d6d5e6e1fda3 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 17:15:46 +0100 Subject: Armor textures support --- builtin/client/cheats/chat.lua | 4 ++-- src/client/game.cpp | 19 ------------------- src/client/game.h | 1 - 3 files changed, 2 insertions(+), 22 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 1f3ecbaa2..0763909df 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -22,10 +22,10 @@ function core.send_colorized(message) message = msg end - local use_chat_color = core.settings:get("use_chat_color") + local use_chat_color = core.settings:get_bool("use_chat_color") local color = core.settings:get("chat_color") - if color then + if use_chat_color and color then local msg if color == "rainbow" then msg = core.rainbow(message) diff --git a/src/client/game.cpp b/src/client/game.cpp index d8800d9ea..2231de353 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2452,9 +2452,6 @@ PointedThing Game::updatePointedThing( ClientEnvironment &env = client->getEnv(); ClientMap &map = env.getClientMap(); const NodeDefManager *nodedef = map.getNodeDefManager(); - - if (g_settings->getBool("killaura")) - handleKillaura(shootline.start, shootline.getLength()); runData.selected_object = NULL; hud->pointing_at_object = false; @@ -2532,22 +2529,6 @@ PointedThing Game::updatePointedThing( return result; } -void Game::handleKillaura(v3f origin, f32 max_d) -{ - ClientEnvironment &env = client->getEnv(); - std::vector allObjects; - env.getActiveObjects(origin, max_d, allObjects); - for (const auto &allObject : allObjects) { - ClientActiveObject *obj = allObject.obj; - s16 id = obj->getId(); - aabb3f selection_box; - if (! obj->getSelectionBox(&selection_box)) - continue; - PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0); - client->interact(INTERACT_START_DIGGING, pointed); - } -} - void Game::handlePointingAtNothing(const ItemStack &playerItem) { infostream << "Right Clicked in Air" << std::endl; diff --git a/src/client/game.h b/src/client/game.h index b8efa3a73..51accc679 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -773,7 +773,6 @@ public: PointedThing updatePointedThing( const core::line3d &shootline, bool liquids_pointable, bool look_for_object, const v3s16 &camera_offset); - void handleKillaura(v3f origin, f32 max_d); void handlePointingAtNothing(const ItemStack &playerItem); void handlePointingAtNode(const PointedThing &pointed, const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime); -- cgit v1.2.3 From 62958bd603f46004de6e31b38721a15f5f34302b Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 17:18:04 +0100 Subject: Reverted accidental commit in wrong repo This reverts commit 00d51fbd56743a4ee091d2956a70d6d5e6e1fda3. --- builtin/client/cheats/chat.lua | 4 ++-- src/client/game.cpp | 19 +++++++++++++++++++ src/client/game.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 0763909df..1f3ecbaa2 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -22,10 +22,10 @@ function core.send_colorized(message) message = msg end - local use_chat_color = core.settings:get_bool("use_chat_color") + local use_chat_color = core.settings:get("use_chat_color") local color = core.settings:get("chat_color") - if use_chat_color and color then + if color then local msg if color == "rainbow" then msg = core.rainbow(message) diff --git a/src/client/game.cpp b/src/client/game.cpp index 2231de353..d8800d9ea 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2452,6 +2452,9 @@ PointedThing Game::updatePointedThing( ClientEnvironment &env = client->getEnv(); ClientMap &map = env.getClientMap(); const NodeDefManager *nodedef = map.getNodeDefManager(); + + if (g_settings->getBool("killaura")) + handleKillaura(shootline.start, shootline.getLength()); runData.selected_object = NULL; hud->pointing_at_object = false; @@ -2529,6 +2532,22 @@ PointedThing Game::updatePointedThing( return result; } +void Game::handleKillaura(v3f origin, f32 max_d) +{ + ClientEnvironment &env = client->getEnv(); + std::vector allObjects; + env.getActiveObjects(origin, max_d, allObjects); + for (const auto &allObject : allObjects) { + ClientActiveObject *obj = allObject.obj; + s16 id = obj->getId(); + aabb3f selection_box; + if (! obj->getSelectionBox(&selection_box)) + continue; + PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0); + client->interact(INTERACT_START_DIGGING, pointed); + } +} + void Game::handlePointingAtNothing(const ItemStack &playerItem) { infostream << "Right Clicked in Air" << std::endl; diff --git a/src/client/game.h b/src/client/game.h index 51accc679..b8efa3a73 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -773,6 +773,7 @@ public: PointedThing updatePointedThing( const core::line3d &shootline, bool liquids_pointable, bool look_for_object, const v3s16 &camera_offset); + void handleKillaura(v3f origin, f32 max_d); void handlePointingAtNothing(const ItemStack &playerItem); void handlePointingAtNode(const PointedThing &pointed, const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime); -- cgit v1.2.3 From 06b72069d8d29c109b8847c9e4ff7948cd79f632 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 17:20:16 +0100 Subject: Fixed ColorChat --- builtin/client/cheats/chat.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 1f3ecbaa2..0763909df 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -22,10 +22,10 @@ function core.send_colorized(message) message = msg end - local use_chat_color = core.settings:get("use_chat_color") + local use_chat_color = core.settings:get_bool("use_chat_color") local color = core.settings:get("chat_color") - if color then + if use_chat_color and color then local msg if color == "rainbow" then msg = core.rainbow(message) -- cgit v1.2.3 From f1d9ac014efc6403e73223f36d3dbb7f5ed50236 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 12:28:00 +0100 Subject: Moved Killaura to Lua; Added ForceField; Added Friendlist; Added ClientObjectRef:is_local_player(); Documented LocalPlayer:get_object() --- builtin/client/cheats/combat.lua | 22 +++++++++++++++++++++- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 4 ++++ doc/client_lua_api.txt | 3 +++ src/client/game.cpp | 19 ------------------- src/client/game.h | 1 - src/defaultsettings.cpp | 2 ++ src/script/lua_api/l_clientobject.cpp | 9 +++++++++ src/script/lua_api/l_clientobject.h | 3 +++ 9 files changed, 43 insertions(+), 21 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/combat.lua b/builtin/client/cheats/combat.lua index 1f9ba9a91..4904d8c52 100644 --- a/builtin/client/cheats/combat.lua +++ b/builtin/client/cheats/combat.lua @@ -4,13 +4,33 @@ local used_sneak = true local totem_move_action = InventoryAction("move") totem_move_action:to("current_player", "main", 9) +core.register_list_command("friend", "Configure Friend List (friends dont get attacked by Killaura or Forcefield)", "friendlist") + core.register_globalstep(function(dtime) local player = core.localplayer if not player then return end local control = player:get_control() local pointed = core.get_pointed_thing() local item = player:get_wielded_item():get_name() - if core.settings:get_bool("crystal_pvp") then + if core.settings:get_bool("killaura") or core.settings:get_bool("forcefield") and control.LMB then + local friendlist = core.settings:get("friendlist"):split(",") + for _, obj in ipairs(core.get_objects_inside_radius(player:get_pos(), 5)) do + local do_attack = true + if obj:is_local_player() then + do_attack = false + else + for _, friend in ipairs(friendlist) do + if obj:get_name() == friend or obj:get_nametag() == friend then + do_attack = false + break + end + end + end + if do_attack then + obj:punch() + end + end + elseif core.settings:get_bool("crystal_pvp") then if placed_crystal then if core.switch_to_item("mobs_mc:totem") then switched_to_totem = 5 diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 6fd78b8b8..466ce4aee 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -1,6 +1,7 @@ core.cheats = { ["Combat"] = { ["Killaura"] = "killaura", + ["Forcefield"] = "forcefield", ["AntiKnockback"] = "antiknockback", ["FastHit"] = "spamclick", ["AttachmentFloat"] = "float_above_parent", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4dcfd1092..ec05c6196 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2314,3 +2314,7 @@ chat_color (Chat Color) string rainbow use_chat_color (ColoredChat) bool false chat_reverse (ReversedChat) bool false + +forcefield (Forcefield) bool false + +friendlist (Killaura / Forcefield Friendlist) string diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt index 2daac87fe..c332ca4c3 100644 --- a/doc/client_lua_api.txt +++ b/doc/client_lua_api.txt @@ -1296,6 +1296,8 @@ Methods: * change a value of a previously added HUD element * element `stat` values: `position`, `name`, `scale`, `text`, `number`, `item`, `dir` * Returns `true` on success, otherwise returns `nil` +* `get_object()` + * Returns the ClientObjectRef for the player ### Settings An interface to read config files in the format of `minetest.conf`. @@ -1336,6 +1338,7 @@ This is basically a reference to a C++ `GenericCAO`. * `get_acceleration()`: returns the acceleration, a vector * `get_rotation()`: returns the rotation, a vector (radians) * `is_player()`: returns true if the object is a player +* `is_local_player()`: returns true if the object is the local player * `get_attach()`: returns parent or nil if it isn't attached. * `get_nametag()`: returns the nametag (string) * `get_item_textures()`: returns the textures diff --git a/src/client/game.cpp b/src/client/game.cpp index d8800d9ea..491d55a34 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2453,9 +2453,6 @@ PointedThing Game::updatePointedThing( ClientMap &map = env.getClientMap(); const NodeDefManager *nodedef = map.getNodeDefManager(); - if (g_settings->getBool("killaura")) - handleKillaura(shootline.start, shootline.getLength()); - runData.selected_object = NULL; hud->pointing_at_object = false; RaycastState s(shootline, look_for_object, liquids_pointable, ! g_settings->getBool("dont_point_nodes")); @@ -2532,22 +2529,6 @@ PointedThing Game::updatePointedThing( return result; } -void Game::handleKillaura(v3f origin, f32 max_d) -{ - ClientEnvironment &env = client->getEnv(); - std::vector allObjects; - env.getActiveObjects(origin, max_d, allObjects); - for (const auto &allObject : allObjects) { - ClientActiveObject *obj = allObject.obj; - s16 id = obj->getId(); - aabb3f selection_box; - if (! obj->getSelectionBox(&selection_box)) - continue; - PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0); - client->interact(INTERACT_START_DIGGING, pointed); - } -} - void Game::handlePointingAtNothing(const ItemStack &playerItem) { infostream << "Right Clicked in Air" << std::endl; diff --git a/src/client/game.h b/src/client/game.h index b8efa3a73..51accc679 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -773,7 +773,6 @@ public: PointedThing updatePointedThing( const core::line3d &shootline, bool liquids_pointable, bool look_for_object, const v3s16 &camera_offset); - void handleKillaura(v3f origin, f32 max_d); void handlePointingAtNothing(const ItemStack &playerItem); void handlePointingAtNode(const PointedThing &pointed, const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e3332b14f..bcdd80074 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -117,6 +117,8 @@ void set_default_settings(Settings *settings) settings->setDefault("chat_color", "rainbow"); settings->setDefault("use_chat_color", "false"); settings->setDefault("chat_reverse", "false"); + settings->setDefault("forcefield", "false"); + settings->setDefault("friendlist", ""); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp index 90f0bcd15..d88b538a1 100644 --- a/src/script/lua_api/l_clientobject.cpp +++ b/src/script/lua_api/l_clientobject.cpp @@ -87,6 +87,14 @@ int ClientObjectRef::l_is_player(lua_State *L) return 1; } +int ClientObjectRef::l_is_local_player(lua_State *L) +{ + ClientObjectRef *ref = checkobject(L, 1); + GenericCAO *gcao = get_generic_cao(ref, L); + lua_pushboolean(L, gcao->isLocalPlayer()); + return 1; +} + int ClientObjectRef::l_get_name(lua_State *L) { ClientObjectRef *ref = checkobject(L, 1); @@ -210,6 +218,7 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos), luamethod(ClientObjectRef, get_acceleration), luamethod(ClientObjectRef, get_rotation), luamethod(ClientObjectRef, is_player), + luamethod(ClientObjectRef, is_local_player), luamethod(ClientObjectRef, get_name), luamethod(ClientObjectRef, get_attach), luamethod(ClientObjectRef, get_nametag), diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h index 88a6956bc..521591444 100644 --- a/src/script/lua_api/l_clientobject.h +++ b/src/script/lua_api/l_clientobject.h @@ -60,6 +60,9 @@ private: // is_player(self) static int l_is_player(lua_State *L); + + // is_local_player(self) + static int l_is_local_player(lua_State *L); // get_name(self) static int l_get_name(lua_State *L); -- cgit v1.2.3 From a7dc1135e94bde5f8c3385d54388563eaffe7553 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 14:19:15 +0100 Subject: Added CheatHUD --- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 2 ++ src/client/game.cpp | 9 ++++-- src/defaultsettings.cpp | 1 + src/gui/cheatMenu.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++ src/gui/cheatMenu.h | 4 +++ 6 files changed, 80 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 466ce4aee..03fc20c60 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -27,6 +27,7 @@ core.cheats = { ["Coords"] = "coords", ["Tracers"] = "enable_tracers", ["ESP"] = "enable_esp", + ["CheatHUD"] = "cheat_hud", }, ["World"] = { ["FastDig"] = "fastdig", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ec05c6196..adb8e7a00 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2318,3 +2318,5 @@ chat_reverse (ReversedChat) bool false forcefield (Forcefield) bool false friendlist (Killaura / Forcefield Friendlist) string + +cheat_hud (CheatHUD) bool true diff --git a/src/client/game.cpp b/src/client/game.cpp index 491d55a34..479484ae9 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -3206,9 +3206,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, Cheat menu */ - if (m_game_ui->m_flags.show_cheat_menu && ! gui_chat_console->isOpen()) - m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug); - + if (! gui_chat_console->isOpen()) { + if (m_game_ui->m_flags.show_cheat_menu) + m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug); + if (g_settings->getBool("cheat_hud")) + m_cheat_menu->drawHUD(driver, dtime); + } /* Damage flash */ diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bcdd80074..9e32a11fe 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -119,6 +119,7 @@ void set_default_settings(Settings *settings) settings->setDefault("chat_reverse", "false"); settings->setDefault("forcefield", "false"); settings->setDefault("friendlist", ""); + settings->setDefault("cheat_hud", "true"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index f796fb0ba..1485541c2 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -94,6 +94,72 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) } } +void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime) +{ + CHEAT_MENU_GET_SCRIPTPTR + + m_rainbow_offset += dtime; + + m_rainbow_offset = fmod(m_rainbow_offset, 6.0f); + + std::vector enabled_cheats; + + int cheat_count = 0; + + for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) { + for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) { + if ((*cheat)->is_enabled()) { + enabled_cheats.push_back((*cheat)->m_name); + cheat_count++; + } + } + } + + if (enabled_cheats.empty()) + return; + + std::vector colors; + + for (int i = 0; i < cheat_count; i++) { + video::SColor color; + f32 h = (f32)i * 2.0f / (f32)cheat_count - m_rainbow_offset; + if (h < 0) + h = 6.0f + h; + f32 x = (1 - fabs(fmod(h, 2.0f) - 1.0f)) * 255.0f; + switch((int)h) { + case 0: + color = video::SColor(255, 255, x, 0); break; + case 1: + color = video::SColor(255, x, 255, 0); break; + case 2: + color = video::SColor(255, 0, 255, x); break; + case 3: + color = video::SColor(255, 0, x, 255); break; + case 4: + color = video::SColor(255, x, 0, 255); break; + case 5: + color = video::SColor(255, 255, 0, x); break; + } + colors.push_back(color); + } + + core::dimension2d screensize = driver->getScreenSize(); + + u32 y = 5; + + int i = 0; + for (std::string cheat : enabled_cheats) { + core::dimension2d dim = m_font->getDimension(utf8_to_wide(cheat).c_str()); + u32 x = screensize.Width - 5 - dim.Width; + + core::rect fontbounds(x, y, x + dim.Width, y + dim.Height); + m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false); + + y += dim.Height; + i++; + } +} + void CheatMenu::selectUp() { CHEAT_MENU_GET_SCRIPTPTR diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index ea9a9d853..f67cdea5a 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -42,6 +42,8 @@ public: CheatMenu(Client *client); void draw(video::IVideoDriver *driver, bool show_debug); + + void drawHUD(video::IVideoDriver *driver, double dtime); void drawEntry(video::IVideoDriver *driver, std::string name, int number, bool selected, bool active, @@ -72,4 +74,6 @@ private: gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; + + float m_rainbow_offset = 0.0; }; -- cgit v1.2.3 From 1799d5aa9ad38b7debbc6b0c4d1e090a68219e1a Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 15:33:48 +0100 Subject: Cheat Menu Improvements Change --- builtin/settingtypes.txt | 20 +++---- fonts/Arimo-Regular-old.ttf | Bin 436876 -> 0 bytes fonts/Arimo-Regular.ttf | Bin 896112 -> 436876 bytes src/defaultsettings.cpp | 14 +++-- src/gui/cheatMenu.cpp | 139 ++++++++++++++++++-------------------------- src/gui/cheatMenu.h | 19 +++--- 6 files changed, 84 insertions(+), 108 deletions(-) delete mode 100644 fonts/Arimo-Regular-old.ttf mode change 100755 => 100644 fonts/Arimo-Regular.ttf (limited to 'builtin') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 620e4b355..74fb5dc92 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2216,27 +2216,27 @@ contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_defa [Cheat Menu] # Font to use for cheat menu -cheat_menu_font (MenuFont) enum FM_Standard, FM_Mono, FM_Fallback, FM_Simple, FM_SimpleMono, FM_MaxMode, FM_Unspecified +cheat_menu_font (MenuFont) enum FM_Mono FM_Standard,FM_Mono,FM_Fallback,FM_Simple,FM_SimpleMono,FM_MaxMode,FM_Unspecified # (RGB value) -m_bg_color (Cell background color) v3f 45 45 68 +cheat_menu_bg_color (Cell background color) v3f 255, 145, 88 -m_bg_color_alpha (Cell background color alpha) int 173 +cheat_menu_bg_color_alpha (Cell background color alpha) int 192 # (RGB value) -m_active_bg_color (Active cell background color) v3f 0 0 0 +cheat_menu_active_bg_color (Active cell background color) v3f 255, 87, 53 -m_active_bg_color_alpha (Active cell background color alpha) int 210 +cheat_menu_active_bg_color_alpha (Active cell background color alpha) int 192 # (RGB value) -m_font_color (Font color) v3f 255 255 255 +cheat_menu_font_color (Font color) v3f 0, 0, 0 -m_font_color_alpha (Font color alpha) int 195 +cheat_menu_font_color_alpha (Font color alpha) int 255 # (RGB value) -m_selected_font_color (Selected font color) v3f 255 255 255 +cheat_menu_selected_font_color (Selected font color) v3f 255, 252, 88 -m_selected_font_color_alpha (Selected font color alpha) int 235 +cheat_menu_selected_font_color_alpha (Selected font color alpha) int 255 [Cheats] @@ -2344,4 +2344,4 @@ forcefield (Forcefield) bool false friendlist (Killaura / Forcefield Friendlist) string -cheat_hud (CheatHUD) bool true \ No newline at end of file +cheat_hud (CheatHUD) bool true diff --git a/fonts/Arimo-Regular-old.ttf b/fonts/Arimo-Regular-old.ttf deleted file mode 100644 index 9be443c7d..000000000 Binary files a/fonts/Arimo-Regular-old.ttf and /dev/null differ diff --git a/fonts/Arimo-Regular.ttf b/fonts/Arimo-Regular.ttf old mode 100755 new mode 100644 index 778d3a059..9be443c7d Binary files a/fonts/Arimo-Regular.ttf and b/fonts/Arimo-Regular.ttf differ diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 619c26eec..347ab7e9c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -65,11 +65,15 @@ void set_default_settings(Settings *settings) settings->setDefault("enable_register_confirmation", "true"); // Cheat Menu - settings->setDefault("cheat_menu_font", "FM_Mono"); - settings->setDefault("m_bg_color_alpha", "173"); - settings->setDefault("m_active_bg_color_alpha", "210"); - settings->setDefault("m_font_color_alpha", "195"); - settings->setDefault("m_selected_font_color_alpha", "235"); + settings->setDefault("cheat_menu_font", "FM_Standard"); + settings->setDefault("cheat_menu_bg_color", "(255, 145, 88)"); + settings->setDefault("cheat_menu_bg_color_alpha", "192"); + settings->setDefault("cheat_menu_active_bg_color", "(255, 87, 53)"); + settings->setDefault("cheat_menu_active_bg_color_alpha", "192"); + settings->setDefault("cheat_menu_font_color", "(0, 0, 0)"); + settings->setDefault("cheat_menu_font_color_alpha", "255"); + settings->setDefault("cheat_menu_selected_font_color", "(255, 252, 88)"); + settings->setDefault("cheat_menu_selected_font_color_alpha", "255"); // Cheats settings->setDefault("xray", "false"); diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 5a7f52477..e66fbc250 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -45,32 +45,29 @@ FontMode CheatMenu::fontStringToEnum(std::string str) { CheatMenu::CheatMenu(Client *client) : m_client(client) { FontMode fontMode = fontStringToEnum(g_settings->get("cheat_menu_font")); - irr::core::vector3df bg_color; - irr::core::vector3df active_bg_color; - irr::core::vector3df font_color; - irr::core::vector3df selected_font_color; + v3f bg_color, active_bg_color, font_color, selected_font_color; - g_settings->getV3FNoEx("m_bg_color", bg_color); - g_settings->getV3FNoEx("m_active_bg_color", active_bg_color); - g_settings->getV3FNoEx("m_font_color", font_color); - g_settings->getV3FNoEx("m_selected_font_color", selected_font_color); + bg_color = g_settings->getV3F("cheat_menu_bg_color"); + active_bg_color = g_settings->getV3F("cheat_menu_active_bg_color"); + font_color = g_settings->getV3F("cheat_menu_font_color"); + selected_font_color = g_settings->getV3F("cheat_menu_selected_font_color"); - m_bg_color = video::SColor(g_settings->getU32("m_bg_color_alpha"), + m_bg_color = video::SColor(g_settings->getU32("cheat_menu_bg_color_alpha"), bg_color.X, bg_color.Y, bg_color.Z); - m_active_bg_color = video::SColor(g_settings->getU32("m_active_bg_color_alpha"), + m_active_bg_color = video::SColor(g_settings->getU32("cheat_menu_active_bg_color_alpha"), active_bg_color.X, active_bg_color.Y, active_bg_color.Z); - m_font_color = video::SColor(g_settings->getU32("m_font_color_alpha"), + m_font_color = video::SColor(g_settings->getU32("cheat_menu_font_color_alpha"), font_color.X, font_color.Y, font_color.Z); - m_selected_font_color = video::SColor(g_settings->getU32("m_selected_font_color_alpha"), + m_selected_font_color = video::SColor(g_settings->getU32("cheat_menu_selected_font_color_alpha"), selected_font_color.X, selected_font_color.Y, selected_font_color.Z); m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, fontMode); if (!m_font) { - errorstream << "CheatMenu: Unable to load fallback font" << std::endl; + errorstream << "CheatMenu: Unable to load font" << std::endl; } else { core::dimension2d dim = m_font->getDimension(L"M"); m_fontsize = v2u32(dim.Width, dim.Height); @@ -80,41 +77,29 @@ CheatMenu::CheatMenu(Client *client) : m_client(client) m_fontsize.Y = MYMAX(m_fontsize.Y, 1); } -void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, - std::size_t column_align_index, std::size_t cheat_entry_index, - bool is_selected, bool is_enabled, CheatMenuEntryType entry_type) +void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, int number, + bool selected, bool active, CheatMenuEntryType entry_type) { int x = m_gap, y = m_gap, width = m_entry_width, height = m_entry_height; video::SColor *bgcolor = &m_bg_color, *fontcolor = &m_font_color; - - // Align with correct column. - x += m_gap + column_align_index * (m_entry_width + m_gap); - - if (is_selected) - fontcolor = &m_selected_font_color; - if (is_enabled) + if (entry_type == CHEAT_MENU_ENTRY_TYPE_HEAD) { bgcolor = &m_active_bg_color; - - switch (entry_type) - { - case CHEAT_MENU_ENTRY_TYPE_HEAD: height = m_head_height; - break; - case CHEAT_MENU_ENTRY_TYPE_CATEGORY: - y += m_head_height + m_gap; - break; - case CHEAT_MENU_ENTRY_TYPE_ENTRY: - y += m_head_height + (cheat_entry_index + 1) * (m_entry_height + m_gap); - break; - default: - // TODO log an error or something. - break; + } else { + bool is_category = entry_type == CHEAT_MENU_ENTRY_TYPE_CATEGORY; + y += m_gap + m_head_height + + (number + (is_category ? 0 : m_selected_category)) * + (m_entry_height + m_gap); + x += (is_category ? 0 : m_gap + m_entry_width); + if (active) + bgcolor = &m_active_bg_color; + if (selected) + fontcolor = &m_selected_font_color; } - driver->draw2DRectangle(*bgcolor, core::rect(x, y, x + width, y + height)); - if (is_selected) + if (selected) driver->draw2DRectangleOutline( - core::rect(x - 2, y - 2, x + width + 1, y + height + 1), + core::rect(x - 1, y - 1, x + width, y + height), *fontcolor); int fx = x + 5, fy = y + (height - m_fontsize.Y) / 2; core::rect fontbounds( @@ -124,26 +109,24 @@ void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) { - ClientScripting *script{ getScript() }; - if (!script || !script->m_cheats_loaded) - return; + CHEAT_MENU_GET_SCRIPTPTR - // Draw menu header if debug info is not being drawn. if (!show_debug) - drawEntry(driver, "Dragonfireclient", 0, 0, false, false, - CHEAT_MENU_ENTRY_TYPE_HEAD); - + drawEntry(driver, "Dragonfireclient", 0, false, false, + CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; - for (const auto &menu_item : script->m_cheat_categories) { + for (auto category = script->m_cheat_categories.begin(); + category != script->m_cheat_categories.end(); category++) { bool is_selected = category_count == m_selected_category; - drawEntry(driver, menu_item->m_name, category_count, 0, is_selected, - false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); + drawEntry(driver, (*category)->m_name, category_count, is_selected, false, + CHEAT_MENU_ENTRY_TYPE_CATEGORY); if (is_selected && m_cheat_layer) { int cheat_count = 0; - for (const auto &sub_menu_item : menu_item->m_cheats) { - drawEntry(driver, sub_menu_item->m_name, category_count, - cheat_count, cheat_count == m_selected_cheat, - sub_menu_item->is_enabled()); + for (auto cheat = (*category)->m_cheats.begin(); + cheat != (*category)->m_cheats.end(); cheat++) { + drawEntry(driver, (*cheat)->m_name, cheat_count, + cheat_count == m_selected_cheat, + (*cheat)->is_enabled()); cheat_count++; } } @@ -217,57 +200,47 @@ void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime) } } -void CheatMenu::selectLeft() +void CheatMenu::selectUp() { CHEAT_MENU_GET_SCRIPTPTR - int max = script->m_cheat_categories.size() - 1; - int *selected = &m_selected_category; + int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category] + ->m_cheats.size() + : script->m_cheat_categories.size()) - + 1; + int *selected = m_cheat_layer ? &m_selected_cheat : &m_selected_category; --*selected; if (*selected < 0) *selected = max; } -void CheatMenu::selectRight() +void CheatMenu::selectDown() { CHEAT_MENU_GET_SCRIPTPTR - int max = script->m_cheat_categories.size() - 1; - int *selected = &m_selected_category; + int max = (m_cheat_layer ? script->m_cheat_categories[m_selected_category] + ->m_cheats.size() + : script->m_cheat_categories.size()) - + 1; + int *selected = m_cheat_layer ? &m_selected_cheat : &m_selected_category; ++*selected; if (*selected > max) *selected = 0; } -void CheatMenu::selectDown() +void CheatMenu::selectRight() { - CHEAT_MENU_GET_SCRIPTPTR - + if (m_cheat_layer) + return; m_cheat_layer = true; - - int max = script->m_cheat_categories[m_selected_category]->m_cheats.size(); - int *selected = &m_selected_cheat; - ++*selected; - if (*selected > max) { - *selected = 1; - } + m_selected_cheat = 0; } -void CheatMenu::selectUp() +void CheatMenu::selectLeft() { - if (!m_cheat_layer) { + if (!m_cheat_layer) return; - } - - CHEAT_MENU_GET_SCRIPTPTR - - int *selected = &m_selected_cheat; - --*selected; - - if (*selected < 0) { - m_cheat_layer = false; - *selected = 1; - } + m_cheat_layer = false; } void CheatMenu::selectConfirm() diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index bedd7e048..8be73c483 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -51,9 +51,8 @@ public: void drawHUD(video::IVideoDriver *driver, double dtime); - void drawEntry(video::IVideoDriver *driver, std::string name, - std::size_t column_align_index, std::size_t cheat_entry_index, - bool is_selected, bool is_enabled, + void drawEntry(video::IVideoDriver *driver, std::string name, int number, + bool selected, bool active, CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY); void selectUp(); @@ -67,15 +66,15 @@ private: int m_selected_cheat = 0; int m_selected_category = 0; - int m_head_height = 20; - int m_entry_height = 20; - int m_entry_width = 150; + int m_head_height = 50; + int m_entry_height = 40; + int m_entry_width = 200; int m_gap = 3; - video::SColor m_bg_color = video::SColor(173, 45, 45, 68); - video::SColor m_active_bg_color = video::SColor(210, 0, 0, 0); - video::SColor m_font_color = video::SColor(195, 255, 255, 255); - video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); + video::SColor m_bg_color = video::SColor(192, 255, 145, 88); + video::SColor m_active_bg_color = video::SColor(192, 255, 87, 53); + video::SColor m_font_color = video::SColor(255, 0, 0, 0); + video::SColor m_selected_font_color = video::SColor(255, 255, 252, 88); FontMode fontStringToEnum(std::string str); -- cgit v1.2.3 From 1145b05ea0bda87dc0827821385810eced08f774 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 15:52:37 +0100 Subject: Updated Credits --- builtin/mainmenu/tab_credits.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index 4f9f835f7..274c8faa5 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -17,10 +17,12 @@ -------------------------------------------------------------------------------- local dragonfire_team = { - "Elias Fleckenstein", - "cora", - "system32", - "DerZombiiie", + "Elias Fleckenstein [Main Developer]", + "cora [Core Developer]", + "emilia [Core Developer]", + "oneplustwo [Developer]", + "joshia_wi [Developer]", + "DerZombiiie [User Support]", } local core_developers = { -- cgit v1.2.3