summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilesdl.h
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-15 04:07:07 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-15 04:07:07 +0000
commitaf3cd3ff34ef5da884b2c673afe1321f0cf372e7 (patch)
treea574c2155f571f216f29c44b29e333ea320322a6 /crawl-ref/source/tilesdl.h
parent71ed1a7fd6819916d79d194126c061ac1f087b11 (diff)
downloadcrawl-ref-af3cd3ff34ef5da884b2c673afe1321f0cf372e7.tar.gz
crawl-ref-af3cd3ff34ef5da884b2c673afe1321f0cf372e7.zip
Large tiles-related changes. Platform-specific rendering removed and replaced with SDL/OpenGL.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6550 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilesdl.h')
-rw-r--r--crawl-ref/source/tilesdl.h186
1 files changed, 186 insertions, 0 deletions
diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h
new file mode 100644
index 0000000000..5f0032ebec
--- /dev/null
+++ b/crawl-ref/source/tilesdl.h
@@ -0,0 +1,186 @@
+/*
+ * File: tilesdl.h
+ * Summary: SDL-related functionality for the tiles port
+ * Written by: Enne Walker
+ */
+
+#ifdef USE_TILE
+#ifndef TILESDL_H
+#define TILESDL_H
+
+#include "debug.h"
+#include "externs.h"
+#include "FixVec.h"
+#include "tilereg.h"
+
+// This struct defines all of the state that any particular rendering needs.
+// If other rendering states are needed, they should be added here so that
+// they do not introduce unneeded side effects for other parts of the code
+// that have not thought about turning that new state off.
+struct GLState
+{
+ GLState();
+
+ // vertex arrays
+ bool array_vertex;
+ bool array_texcoord;
+ bool array_colour;
+
+ // render state
+ bool blend;
+ bool texture;
+};
+
+enum key_mod
+{
+ MOD_SHIFT = 0x1,
+ MOD_CTRL = 0x2,
+ MOD_ALT = 0x4
+};
+
+struct MouseEvent
+{
+ enum mouse_event_type
+ {
+ PRESS,
+ RELEASE,
+ MOVE
+ };
+
+ enum mouse_event_button
+ {
+ NONE = 0x00,
+ LEFT = 0x01,
+ MIDDLE = 0x02,
+ RIGHT = 0x04,
+ SCROLL_UP = 0x08,
+ SCROLL_DOWN = 0x10
+ };
+
+ // kind of event
+ mouse_event_type event;
+ // if PRESS or RELEASE, the button pressed
+ mouse_event_button button;
+ // bitwise-or of buttons currently pressed
+ unsigned short held;
+ // bitwise-or of key mods currently pressed
+ unsigned char mod;
+ // location of events in pixels and in window coordinate space
+ unsigned int px;
+ unsigned int py;
+};
+
+class GLStateManager
+{
+public:
+ static void init();
+ static void set(const GLState& state);
+};
+
+class SDL_Surface;
+class FTFont;
+
+class TilesFramework
+{
+public:
+ TilesFramework();
+ virtual ~TilesFramework();
+
+ bool initialise();
+ void shutdown();
+ void load_dungeon(unsigned int *tileb, int gx, int gy);
+ void load_dungeon(int gx, int gy);
+ int getch();
+ int getch_ck();
+ void resize();
+ void clrscr();
+
+ void message_out(int which_line, int colour, const char *s, int firstcol, bool newline);
+
+ void cgotoxy(int x, int y, int region = GOTO_CRT);
+ void clear_message_window();
+
+ void update_minimap(int gx, int gy, map_feature f);
+ void clear_minimap();
+ void update_inventory();
+
+ void update_menu_inventory(unsigned int slot, const item_def &item, bool selected, char key);
+
+ void redraw();
+
+ void place_cursor(cursor_type type, const coord_def &gc);
+ void clear_text_tags(text_tag_type type);
+ void add_text_tag(text_tag_type type, const std::string &tag,
+ const coord_def &gc);
+
+ bool initialise_items();
+
+ const coord_def &get_cursor() const;
+protected:
+
+ bool load_font(const char *font_file, int font_size);
+ int handle_mouse(MouseEvent &event);
+
+ // screen pixel dimensions
+ coord_def m_windowsz;
+ // screen pixels per view cell
+ coord_def m_viewsc;
+
+ SDL_Surface* m_context;
+ bool m_fullscreen;
+
+ enum LayerID
+ {
+ LAYER_NORMAL,
+ LAYER_CRT,
+ LAYER_TITLE,
+ LAYER_MAX
+ };
+
+ class Layer
+ {
+ public:
+ // Layers don't own these regions
+ std::vector<Region*> m_regions;
+ };
+ Layer m_layers[LAYER_MAX];
+ LayerID m_active_layer;
+
+ // Normal layer
+ DungeonRegion *m_region_tile;
+ StatRegion *m_region_stat;
+ MessageRegion *m_region_msg;
+ MapRegion *m_region_map;
+ InventoryRegion *m_region_self_inv;
+
+ // Full-screen CRT layer
+ CRTRegion *m_region_crt;
+ InventoryRegion *m_region_menu_inv;
+
+ FTFont *m_font;
+
+ void do_layout();
+
+ ImageManager m_image;
+
+ // Mouse state.
+ unsigned short m_buttons_held;
+ unsigned char m_key_mod;
+ coord_def m_mouse;
+ unsigned int m_last_tick_moved;
+
+ std::string m_tooltip;
+};
+
+// Main interface for tiles functions
+extern TilesFramework tiles;
+
+#ifdef __MINGW32__
+#ifndef alloca
+// Srsly, MinGW, wtf?
+void *alloca(size_t);
+#endif
+#endif
+
+#endif
+#endif