Attached Files |
godmenu.patch [^] (2,853 bytes) 2011-09-21 20:41 [Show Content] [Hide Content]From 78aa1add5dc058a01b12f5e397740ae8557f1a76 Mon Sep 17 00:00:00 2001
From: ldierk <lothar.dierkes@googlemail.com>
Date: Wed, 21 Sep 2011 20:39:06 +0200
Subject: [PATCH] new hotkeys and colours for ?/G
---
crawl-ref/source/command.cc | 2 ++
crawl-ref/source/menu.cc | 29 +++++++++++++++++++++++++++++
crawl-ref/source/menu.h | 11 +++++++++++
3 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 755613e..b1a7129 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1814,6 +1814,8 @@ static void _find_description(bool *again, std::string *error_inout)
}
else if (doing_features)
me = new FeatureMenuEntry(str, feat_by_desc(str), letter);
+ else if (doing_gods)
+ me = new GodMenuEntry(key_list[i]);
else
{
me = new MenuEntry(uppercase_first(key_list[i]), MEL_ITEM, 1,
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index a97b4fc..fef533c 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -18,6 +18,8 @@
#include "options.h"
#include "player.h"
#include "hints.h"
+#include "religion.h"
+#include "colour.h"
#ifdef USE_TILE_LOCAL
#include "mon-stuff.h"
@@ -819,6 +821,33 @@ void Menu::select_items(int key, int qty)
cgotoxy(x, y);
}
+GodMenuEntry::GodMenuEntry(const std::string& txt ) : MenuEntry( txt, MEL_ITEM, 1, 0, false )
+{
+ god = str_to_god(txt);
+ if (god == GOD_SHINING_ONE)
+ hotkeys.push_back('1');
+ else
+ {
+ //hotkeys.push_back(txt.at(0));
+ hotkeys.push_back(tolower(txt.at(0)));
+ }
+ int c = god_colour(god);
+ colour_text = colour_to_str(c);
+ data = &text;
+}
+
+std::string GodMenuEntry::get_text(const bool unused) const
+{
+ if (level == MEL_ITEM && hotkeys.size())
+ {
+ char buf[300];
+ snprintf(buf, sizeof buf, " <%s>%c</%s> %c %s", colour_text.c_str(),
+ hotkeys[0], colour_text.c_str(), preselected ? '+' : '-', text.c_str());
+ return std::string(buf);
+ }
+ return text;
+}
+
MonsterMenuEntry::MonsterMenuEntry(const std::string &str, const monster* mon,
int hotkey) :
MenuEntry(str, MEL_ITEM, 1, hotkey)
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 87af32d..802be39 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -191,6 +191,17 @@ public:
#endif
};
+class GodMenuEntry : public MenuEntry
+{
+public:
+ GodMenuEntry(const std::string& txt = std::string());
+
+ virtual std::string get_text(const bool unused = false) const;
+private:
+ god_type god;
+ std::string colour_text;
+};
+
#ifdef USE_TILE_LOCAL
class PlayerMenuEntry : public MenuEntry
{
--
1.7.4.1
altar_colours.patch [^] (786 bytes) 2011-09-21 22:17 [Show Content] [Hide Content]From bca338e2a477c8fcb40dae89eb04f34164e07c86 Mon Sep 17 00:00:00 2001
From: ldierk <lothar.dierkes@googlemail.com>
Date: Wed, 21 Sep 2011 22:15:25 +0200
Subject: [PATCH] ?/G uses altar colours
---
crawl-ref/source/menu.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 555802f..ab2fe5d 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -831,7 +831,7 @@ GodMenuEntry::GodMenuEntry(const std::string& txt) : MenuEntry(txt, MEL_ITEM, 1,
//hotkeys.push_back(txt.at(0));
hotkeys.push_back(tolower(txt.at(0)));
}
- int c = god_colour(god);
+ int c = god_message_altar_colour(god);
colour_text = colour_to_str(c);
data = &text;
}
--
1.7.4.1
singleselect.patch [^] (3,817 bytes) 2011-09-22 12:57 [Show Content] [Hide Content]From 629d3d14c48a80e00db833617f0a2644ba9d2f90 Mon Sep 17 00:00:00 2001
From: ldierk <lothar.dierkes@googlemail.com>
Date: Thu, 22 Sep 2011 12:59:00 +0200
Subject: [PATCH 1/2] Allow MenuEntrys in MF_SINGLESELECT menus to use more than one hotkey
---
crawl-ref/source/command.cc | 2 +-
crawl-ref/source/menu.cc | 20 ++++++--------------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index b1a7129..729d434 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1854,7 +1854,7 @@ static void _find_description(bool *again, std::string *error_inout)
else
{
ASSERT(sel.size() == 1);
- ASSERT(sel[0]->hotkeys.size() == 1);
+ ASSERT(sel[0]->hotkeys.size() >= 1);
std::string key;
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index ab2fe5d..bf25f66 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -742,8 +742,7 @@ bool Menu::is_hotkey(int i, int key)
int end = first_entry + pagesize;
if (end > static_cast<int>(items.size())) end = items.size();
- bool ishotkey = (is_set(MF_SINGLESELECT) ? items[i]->is_primary_hotkey(key)
- : items[i]->is_hotkey(key));
+ bool ishotkey = items[i]->is_hotkey(key);
return !is_set(MF_SELECT_BY_PAGE) ? ishotkey
: ishotkey && i >= first_entry && i < end;
@@ -773,8 +772,7 @@ void Menu::select_items(int key, int qty)
// are usually separated by at least a page, so we should
// only select the item on the current page. This is why we
// use two loops, and check to see if we've matched an item
- // by its primary hotkey (which is assumed to always be
- // hotkeys[0]), in which case, we stop selecting further
+ // by its hotkey, in which case, we stop selecting further
// items.
const bool check_preselected = (key == CK_ENTER);
for (int i = first_entry; i < final; ++i)
@@ -788,11 +786,8 @@ void Menu::select_items(int key, int qty)
else if (is_hotkey(i, key))
{
select_index(i, qty);
- if (items[i]->hotkeys[0] == key)
- {
- selected = true;
- break;
- }
+ selected = true;
+ break;
}
}
@@ -809,11 +804,8 @@ void Menu::select_items(int key, int qty)
else if (is_hotkey(i, key))
{
select_index(i, qty);
- if (items[i]->hotkeys[0] == key)
- {
- selected = true;
- break;
- }
+ selected = true;
+ break;
}
}
}
--
1.7.4.1
From fbca3f0f78c78b20b60697d7bb2cf26dd2fdcb9c Mon Sep 17 00:00:00 2001
From: ldierk <lothar.dierkes@googlemail.com>
Date: Thu, 22 Sep 2011 12:09:50 +0200
Subject: [PATCH 2/2] Make /?G display uppercase hotkey, but allow upper- and lowercase hotkeys
---
crawl-ref/source/menu.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index bf25f66..c9a8520 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -820,7 +820,7 @@ GodMenuEntry::GodMenuEntry(const std::string& txt) : MenuEntry(txt, MEL_ITEM, 1,
hotkeys.push_back('1');
else
{
- //hotkeys.push_back(txt.at(0));
+ hotkeys.push_back(txt.at(0));
hotkeys.push_back(tolower(txt.at(0)));
}
int c = god_message_altar_colour(god);
--
1.7.4.1
primary_hotkey.patch [^] (1,887 bytes) 2011-09-22 12:57 [Show Content] [Hide Content]From 399007e25080c07ea75952bdeb6fa873f81dd02e Mon Sep 17 00:00:00 2001
From: ldierk <lothar.dierkes@googlemail.com>
Date: Thu, 22 Sep 2011 12:46:34 +0200
Subject: [PATCH] Make Menu::select_items use is_primary_hotkey instead of accessing the hotkeys directly
---
crawl-ref/source/menu.cc | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index ab2fe5d..3bc6368 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -773,9 +773,8 @@ void Menu::select_items(int key, int qty)
// are usually separated by at least a page, so we should
// only select the item on the current page. This is why we
// use two loops, and check to see if we've matched an item
- // by its primary hotkey (which is assumed to always be
- // hotkeys[0]), in which case, we stop selecting further
- // items.
+ // by its primary hotkey in which case, we stop selecting
+ // further items.
const bool check_preselected = (key == CK_ENTER);
for (int i = first_entry; i < final; ++i)
{
@@ -788,7 +787,7 @@ void Menu::select_items(int key, int qty)
else if (is_hotkey(i, key))
{
select_index(i, qty);
- if (items[i]->hotkeys[0] == key)
+ if (items[i]->is_primary_hotkey(key))
{
selected = true;
break;
@@ -809,7 +808,7 @@ void Menu::select_items(int key, int qty)
else if (is_hotkey(i, key))
{
select_index(i, qty);
- if (items[i]->hotkeys[0] == key)
+ if (items[i]->is_primary_hotkey(key))
{
selected = true;
break;
--
1.7.4.1
|