summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authorfrogbotherer <therealchriswest@hotmail.com>2012-09-08 13:40:44 +0200
committerRaphael Langella <raphael.langella@gmail.com>2012-09-08 13:40:44 +0200
commitf4002528321dbb23f92bade00d46ce515dd1bd27 (patch)
treec4c8a91fdbe7f14f4a6d66f59f0b1e8429a553f8 /crawl-ref/source/menu.cc
parent58ccbffacfa6feedebee83d6fc22b9037f29bf92 (diff)
downloadcrawl-ref-f4002528321dbb23f92bade00d46ce515dd1bd27.tar.gz
crawl-ref-f4002528321dbb23f92bade00d46ce515dd1bd27.zip
Android port.
2 files are added to the root of the repository: * AndroidAppSettings.cfg: settings file required for Android SDL port. Will change on each minor release to reset configuration. * AndroidBuild.sh: script called by the Android SDL port to commence building the game itself It might be nice to be able to move them elsewhere, but for now, their presence here is required. The build process is documented in docs/develop/android.txt There's a TOUCH_UI compiler flag which sets all the things specific to a touch screen interface. There has been a large amount of changes in the Makefile for redefining where the dat/, saves/, etc. directories go, because the "install" part of the make isn't the final destination for these files under Android - the environment we deploy to is a separate device from the build environment. There is also a number of changes to the tiles interface. Some are specific to the TOUCH_UI, but others are also changed in USE_TILE_LOCAL. Touch only: * 'a'bilities menu goes straight to menu without prompting first * tap menu header to toggle/submit * menu instead of prompt to select which corpse to butcher * same for eating food from the floor (those 2 could go in local tiles too) * show_more defaults to false and less --more-- messages * pickup mode defaults to menu * defaults for tile_layout_priority is different (commands are more important than inventory) * popup for yes/no prompts, level-up stat gain and swapping rings (should be used for all prompts, and probably local tiles too) * spell casting: force selection menu * map mode: left-click rather than right-click for mouse mode; autotravel on left-click removed * remove skills training and memorisation panels Also local tiles (some could also be integrated in webtiles): * commands below description are clickable * clickable shopping menu (uses PrecisionMenu) * split the command panel in 2 (common actions and system commands) * add a map command panel * tapping or left-clicking the player is smarter: * picks up the item if there's one on the tile, otherwise * shows pick-up menu if there's several items on the tile, otherwise * traverses stairs (or enters a portal or shop) if one is present, otherwise * prays if an altar is present, otherwise * waits one turn * right-clicking the map enters map mode and brings the map commands tab to the front; map mode stays until exited rather than upon release of mouse Some more details can be found in android_patch_notes.txt on #5677 (although some TODOs are already obsolete). Signed-off-by: Raphael Langella <raphael.langella@gmail.com>
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc73
1 files changed, 72 insertions, 1 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 62545b2770..70b9db627e 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -26,6 +26,7 @@
#include "tilefont.h"
#include "tilereg-crt.h"
#include "tilereg-menu.h"
+ #include "tilereg-popup.h"
#endif
#ifdef USE_TILE
#include "mon-stuff.h"
@@ -40,6 +41,39 @@
#include "travel.h"
#endif
+#ifdef USE_TILE_LOCAL
+Popup::Popup(string prompt = "") : m_prompt(prompt), m_curr(0)
+{
+}
+
+void Popup::set_prompt(string prompt)
+{
+ m_prompt = prompt;
+}
+
+void Popup::push_entry(MenuEntry *me)
+{
+ m_entries.push_back(me);
+}
+
+MenuEntry* Popup::next_entry()
+{
+ if (m_curr >= m_entries.size())
+ {
+ m_curr = 0;
+ return NULL;
+ }
+ MenuEntry *me = m_entries[m_curr];
+ m_curr ++;
+ return me;
+}
+
+int Popup::pop()
+{
+ return tiles.draw_popup(this);
+}
+#endif
+
MenuDisplay::MenuDisplay(Menu *menu) : m_menu(menu)
{
m_menu->set_maxpagesize(get_number_of_lines());
@@ -338,7 +372,12 @@ bool Menu::process_key(int keyin)
lastch = keyin;
return false;
}
+#ifdef TOUCH_UI
+ else if (action_cycle == CYCLE_TOGGLE && (keyin == '!' || keyin == '?'
+ || keyin == CK_TOUCH_DUMMY))
+#else
else if (action_cycle == CYCLE_TOGGLE && (keyin == '!' || keyin == '?'))
+#endif
{
ASSERT(menu_action != ACT_MISC);
if (menu_action == ACT_EXECUTE)
@@ -350,7 +389,12 @@ bool Menu::process_key(int keyin)
update_title();
return true;
}
+#ifdef TOUCH_UI
+ else if (action_cycle == CYCLE_CYCLE && (keyin == '!' || keyin == '?'
+ || keyin == CK_TOUCH_DUMMY))
+#else
else if (action_cycle == CYCLE_CYCLE && (keyin == '!' || keyin == '?'))
+#endif
{
menu_action = (action)((menu_action+1) % ACT_NUM);
sel.clear();
@@ -367,8 +411,10 @@ bool Menu::process_key(int keyin)
switch (keyin)
{
+#ifndef TOUCH_UI
case 0:
return true;
+#endif
case CK_MOUSE_B2:
case CK_MOUSE_CMD:
CASE_ESCAPE
@@ -526,6 +572,12 @@ bool Menu::process_key(int keyin)
repaint = true;
break;
+#ifdef TOUCH_UI
+ case CK_TOUCH_DUMMY: // mouse click in top/bottom region of menu
+ case 0: // do the same as <enter> key
+ if (!(flags & MF_MULTISELECT)) // bail out if not a multi-select
+ return true;
+#endif
case CK_ENTER:
if (!(flags & MF_PRESELECTED) || !sel.empty())
return false;
@@ -1922,6 +1974,11 @@ bool formatted_scroller::process_key(int keyin)
{
lastch = keyin;
+#ifdef TOUCH_UI
+ if(keyin == CK_TOUCH_DUMMY) // mouse click in title area, which
+ return true; // wouldn't usually be handled
+#endif
+
if (f_keyfilter)
keyin = (*f_keyfilter)(keyin);
@@ -1986,7 +2043,12 @@ bool formatted_scroller::process_key(int keyin)
int ToggleableMenu::pre_process(int key)
{
+#ifdef TOUCH_UI
+ if (find(toggle_keys.begin(), toggle_keys.end(), key) != toggle_keys.end()
+ || key == CK_TOUCH_DUMMY)
+#else
if (find(toggle_keys.begin(), toggle_keys.end(), key) != toggle_keys.end())
+#endif
{
// Toggle all menu entries
for (unsigned int i = 0; i < items.size(); ++i)
@@ -2023,7 +2085,11 @@ int ToggleableMenu::pre_process(int key)
}
// Don't further process the key
+#ifdef TOUCH_UI
+ return CK_TOUCH_DUMMY;
+#else
return 0;
+#endif
}
return key;
}
@@ -2127,6 +2193,10 @@ bool PrecisionMenu::process_key(int key)
}
}
+#ifdef TOUCH_UI
+ if (key == CK_TOUCH_DUMMY)
+ return true; // mouse click in title area, which wouldn't usually be handled
+#endif
// Handle CK_MOUSE_CLICK separately
// This signifies a menu ending action
if (key == CK_MOUSE_CLICK)
@@ -2213,7 +2283,7 @@ int PrecisionMenu::handle_mouse(const MouseEvent &me)
{
// Feed input to each attached object that the mouse is over
// The objects are responsible for processing the input
- // This includes, if applicaple for instance checking if the mouse
+ // This includes, if applicable for instance checking if the mouse
// is over the item or not
MenuObject::InputReturnValue input_return = MenuObject::INPUT_NO_ACTION;
@@ -2221,6 +2291,7 @@ int PrecisionMenu::handle_mouse(const MouseEvent &me)
for (it = m_attached_objects.begin(); it != m_attached_objects.end(); ++it)
{
input_return = (*it)->handle_mouse(me);
+
switch (input_return)
{
case MenuObject::INPUT_SELECTED: