diff options
-rw-r--r-- | crawl-ref/settings/tiles_options.txt | 44 | ||||
-rw-r--r-- | crawl-ref/source/defines.h | 7 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/libgui.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/libgui.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 115 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.h | 5 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.cc | 178 | ||||
-rw-r--r-- | crawl-ref/source/tilesdl.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 6 |
10 files changed, 322 insertions, 48 deletions
diff --git a/crawl-ref/settings/tiles_options.txt b/crawl-ref/settings/tiles_options.txt index 058569ad6d..03b7a98e5a 100644 --- a/crawl-ref/settings/tiles_options.txt +++ b/crawl-ref/settings/tiles_options.txt @@ -1,7 +1,7 @@ ### The following lines define the colours of various objects within the ### tiles minimap. See options_guide.txt for more details. -tile_show_items = !?/%=([)X}+\_. +# tile_show_items = !?/%=([)X}+\_. # tile_title_screen = false @@ -26,6 +26,13 @@ tile_show_items = !?/%=([)X}+\_. # tile_excl_centre = darkblue # tile_window_col = yellow +# tile_tooltip_ms = 1000 + +# tile_window_width = 1024 +# tile_window_height = 768 +# tile_map_pixels = 4 +# tile_full_screen = true + # tile_font_crt_file = VeraMono.ttf # tile_font_crt_size = 15 # tile_font_stat_file = VeraMono.ttf @@ -37,8 +44,37 @@ tile_show_items = !?/%=([)X}+\_. # tile_font_lbl_file = Vera.ttf # tile_font_lbl_size = 14 +### Predefined layouts for smaller standard resolutions. Any window size +### at or above 1024x768 should probably use the above defaults. + +### 800 x 480 (EeePC) +# tile_window_width = 800 +# tile_window_height = 480 +# tile_map_pixels = 3 # tile_full_screen = true +# tile_font_crt_size = 13 +# tile_font_stat_size = 12 +# tile_font_msg_size = 10 +# tile_font_tip_size = 13 +# tile_font_lbl_size = 11 + +### 1024 x 600 (EeePC 900+) # tile_window_width = 1024 -# tile_window_height = 768 -# tile_map_pixels = 4 -# tile_tooltip_ms = 1000 +# tile_window_height = 600 +# tile_map_pixels = 3 +# tile_full_screen = true +# tile_font_crt_size = 14 +# tile_font_stat_size = 14 +# tile_font_msg_size = 12 +# tile_font_tip_size = 13 +# tile_font_lbl_size = 12 + +### 800 x 600 +# tile_window_width = 800 +# tile_window_height = 600 +# tile_map_pixels = 3 +# tile_font_crt_size = 14 +# tile_font_stat_size = 11 +# tile_font_msg_size = 12 +# tile_font_tip_size = 13 +# tile_font_lbl_size = 12 diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h index b61107ff13..64a302156c 100644 --- a/crawl-ref/source/defines.h +++ b/crawl-ref/source/defines.h @@ -120,15 +120,10 @@ const int LABYRINTH_BORDER = 4; #define ENV_SHOW_OFFSET (LOS_RADIUS + 1) #define ENV_SHOW_DIAMETER (ENV_SHOW_OFFSET * 2 + 1) -#ifdef USE_TILE -#define VIEW_BASE_WIDTH (tile_dngn_x) -#define VIEW_MIN_WIDTH (tile_dngn_x) -#define VIEW_MIN_HEIGHT (tile_dngn_y) -#else #define VIEW_BASE_WIDTH 33 #define VIEW_MIN_WIDTH 17 #define VIEW_MIN_HEIGHT 17 -#endif +#define MSG_MIN_HEIGHT 7 // max traps per level #define MAX_TRAPS 100 diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 3d09caef7d..91d8838aef 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -828,7 +828,7 @@ void game_options::reset_options() #endif #ifdef USE_TILE - tile_show_items[0] = '0'; + strcpy(tile_show_items, "!?/%=([)X}+\\_."); tile_title_screen = true; // minimap colours tile_player_col = MAP_WHITE; diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index d0e3414578..2c2befc188 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -47,9 +47,6 @@ #include <SDL.h> #include "tilesdl.h" -int tile_dngn_x; -int tile_dngn_y; - int tile_idx_unseen_terrain(int x, int y, int what) { const coord_def gc(x,y); @@ -292,12 +289,12 @@ int wherey() int get_number_of_lines() { - return 30; + return tiles.get_number_of_lines(); } int get_number_of_cols() { - return 80; + return tiles.get_number_of_cols(); } void put_colour_ch(int colour, unsigned ch) diff --git a/crawl-ref/source/libgui.h b/crawl-ref/source/libgui.h index 1c2b3f747a..7e1018f1d7 100644 --- a/crawl-ref/source/libgui.h +++ b/crawl-ref/source/libgui.h @@ -16,10 +16,6 @@ typedef unsigned int screen_buffer_t; -//dungeon display size -extern int tile_dngn_x; -extern int tile_dngn_y; - void set_mouse_enabled(bool enabled); struct coord_def; diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index fd8066aebb..70c9640f47 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -143,6 +143,9 @@ void Region::resize_to_fit(int _wx, int _wy) my = dy ? inner_y / dy : 0; recalculate(); + + ex = sx + _wx; + ey = sy + _wy; } void Region::recalculate() @@ -161,7 +164,6 @@ Region::~Region() bool Region::inside(unsigned int x, unsigned int y) { - // TODO enne - need to handle invalid/unintialised regions? return (x >= sx && y >= sy && x <= ex && y <= ey); } @@ -754,10 +756,10 @@ void DungeonRegion::draw_foreground(unsigned int bg, unsigned int fg, unsigned i add_quad(TEX_DEFAULT, TILE_ANIMATED_WEAPON, x, y); } - if (bg & TILE_FLAG_UNSEEN) + if (bg & TILE_FLAG_UNSEEN && (bg != TILE_FLAG_UNSEEN || fg)) add_quad(TEX_DEFAULT, TILE_MESH, x, y); - if (bg & TILE_FLAG_MM_UNSEEN) + if (bg & TILE_FLAG_MM_UNSEEN && (bg != TILE_FLAG_MM_UNSEEN || fg)) add_quad(TEX_DEFAULT, TILE_MAGIC_MAP_MESH, x, y); // Don't let the "new stair" icon cover up any existing icons, but @@ -2117,9 +2119,6 @@ TextRegion::TextRegion(FTFont *font) : dx = m_font->char_width(); dy = m_font->char_height(); - - // TODO enne - gah! - dx = 8; } void TextRegion::on_resize() @@ -2343,7 +2342,7 @@ bool StatRegion::update_tip_text(std::string& tip) return true; } -MessageRegion::MessageRegion(FTFont *font) : TextRegion(font) +MessageRegion::MessageRegion(FTFont *font) : TextRegion(font), m_overlay(false) { } @@ -2374,6 +2373,80 @@ bool MessageRegion::update_tip_text(std::string& tip) return true; } +void MessageRegion::set_overlay(bool is_overlay) +{ + m_overlay = is_overlay; +} + +struct box_vert +{ + float x; + float y; + unsigned char r; + unsigned char g; + unsigned char b; + unsigned char a; +}; + +void MessageRegion::render() +{ + if (m_overlay) + { + unsigned int height; + bool found = false; + for (height = my; height > 0; height--) + { + unsigned char *buf = &cbuf[mx * (height - 1)]; + for (unsigned int x = 0; x < mx; x++) + { + if (buf[x] != ' ') + { + found = true; + break; + } + } + + if (found) + break; + } + + if (height > 0) + { + height *= m_font->char_height(); + box_vert verts[4]; + for (unsigned int i = 0; i < 4; i++) + { + verts[i].r = 100; + verts[i].g = 100; + verts[i].b = 100; + verts[i].a = 100; + } + verts[0].x = sx; + verts[0].y = sy; + verts[1].x = sx; + verts[1].y = sy + height; + verts[2].x = ex; + verts[2].y = sy + height; + verts[3].x = ex; + verts[3].y = sy; + + glLoadIdentity(); + + GLState state; + state.array_vertex = true; + state.array_colour = true; + state.blend = true; + GLStateManager::set(state); + + glVertexPointer(2, GL_FLOAT, sizeof(box_vert), &verts[0].x); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(box_vert), &verts[0].r); + glDrawArrays(GL_QUADS, 0, sizeof(verts) / sizeof(box_vert)); + } + } + + m_font->render_textblock(sx + ox, sy + oy, cbuf, abuf, mx, my, m_overlay); +} + CRTRegion::CRTRegion(FTFont *font) : TextRegion(font) { } @@ -2486,7 +2559,7 @@ static void _copy_under(unsigned char *pixels, unsigned int width, { size_t image_size = 32 * 32 * 4; - // Make a copy of the original images on the stack. + // Make a copy of the original images. unsigned char *under = new unsigned char[image_size]; _copy_into(under, pixels, width, height, idx_under); unsigned char *over = new unsigned char[image_size]; @@ -2534,7 +2607,31 @@ static bool _process_item_image(unsigned char *pixels, int tile1 = TILE_ROD_SMITING + i - STAFF_SMITING; _copy_under(pixels, width, height, tile0, tile1); } - + + // TODO enne - fix rtiles so that it can accept PNGs. + { + size_t image_size = 32 * 32 * 4; + unsigned char *mesh = new unsigned char[image_size]; + + for (unsigned int i = 0; i < image_size; i += 4) + { + mesh[i] = mesh[i+1] = mesh[i+2] = 0; + mesh[i+3] = 110; + } + _copy_onto(pixels, width, height, mesh, TILE_MESH, false); + + for (unsigned int i = 0; i < image_size; i += 4) + { + mesh[i] = 70; + mesh[i+1] = 70; + mesh[i+2] = 180; + mesh[i+3] = 120; + } + _copy_onto(pixels, width, height, mesh, TILE_MAGIC_MAP_MESH, false); + + delete[] mesh; + } + return true; } diff --git a/crawl-ref/source/tilereg.h b/crawl-ref/source/tilereg.h index 50c6317526..3f658ca377 100644 --- a/crawl-ref/source/tilereg.h +++ b/crawl-ref/source/tilereg.h @@ -161,8 +161,13 @@ class MessageRegion : public TextRegion public: MessageRegion(FTFont *font); + void set_overlay(bool is_overlay); + virtual int handle_mouse(MouseEvent &event); + virtual void render(); virtual bool update_tip_text(std::string &tip); +protected: + bool m_overlay; }; class CRTRegion : public TextRegion diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 206831be25..b768c8abf9 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -310,11 +310,6 @@ void TilesFramework::resize() glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // TODO enne - need better resizing - // View size in pixels is (m_viewsc * crawl_view.viewsz) - m_viewsc.x = 32; - m_viewsc.y = 32; - // For ease, vertex positions are pixel positions. glOrtho(0, m_windowsz.x, m_windowsz.y, 0, 0, 100); } @@ -647,44 +642,177 @@ int TilesFramework::getch_ck() void TilesFramework::do_layout() { - const int map_stat_buffer = 5; + // View size in pixels is (m_viewsc * crawl_view.viewsz) + m_viewsc.x = 32; + m_viewsc.y = 32; - // TODO enne - use options + const int map_stat_buffer = 4; const int crt_width = 80; const int crt_height = 30; const int map_margin = 2; - // Size regions that we know about + crawl_view.viewsz.x = Options.view_max_width; + crawl_view.viewsz.y = Options.view_max_height; + crawl_view.msgsz.x = crt_width; + + // Initial sizes. + m_region_tile->dx = m_viewsc.x; + m_region_tile->dy = m_viewsc.y; m_region_tile->resize(crawl_view.viewsz.x, crawl_view.viewsz.y); m_region_crt->resize(crt_width, crt_height); m_region_stat->resize(crawl_view.hudsz.x, crawl_view.hudsz.y); m_region_msg->resize(crawl_view.msgsz.x, crawl_view.msgsz.y); m_region_map->resize(GXM, GYM); - + m_region_menu_inv->resize(24, 1); // Place regions for normal layer const int margin = 4; + m_region_tile->place(0, 0, margin); - m_region_msg->place(0, m_region_tile->ey, margin); + m_region_msg->place(0, m_region_tile->ey - margin, margin); + + bool message_overlay = false; + + if (m_windowsz.y < m_region_tile->dy * VIEW_MIN_HEIGHT) + { + crawl_view.viewsz.x = VIEW_MIN_WIDTH; + crawl_view.viewsz.y = VIEW_MIN_HEIGHT; + m_region_tile->place(0, 0, 0); + int factor = m_windowsz.y / crawl_view.viewsz.y; + m_viewsc.x = m_viewsc.y = std::min(32, factor); + m_region_tile->dx = m_viewsc.x; + m_region_tile->dy = m_viewsc.y; + m_region_tile->resize(crawl_view.viewsz.x, crawl_view.viewsz.y); + m_region_msg->place(0, 0, 0); + message_overlay = true; + } + else + { + // Shrink viewsz if too wide: + while (m_region_tile->wx + m_region_stat->wx > m_windowsz.x + && crawl_view.viewsz.x > VIEW_MIN_WIDTH) + { + crawl_view.viewsz.x -= 2; + m_region_tile->mx = crawl_view.viewsz.x; + m_region_tile->place(0, 0, margin); + m_region_msg->place(0, m_region_tile->ex, margin); + } + + // Shrink viewsz if too tall: + while (m_region_tile->wy + m_region_msg->wy > m_windowsz.y + && crawl_view.viewsz.y > VIEW_MIN_HEIGHT) + { + crawl_view.viewsz.y -= 2; + m_region_tile->my = crawl_view.viewsz.y; + m_region_tile->place(0, 0, margin); + m_region_msg->place(0, m_region_tile->ey, margin); + } - int stat_col = m_region_tile->ex + map_stat_buffer; + // Shrink msgsz if too tall: + while (m_region_tile->wy + m_region_msg->wy > m_windowsz.y + && crawl_view.msgsz.y > MSG_MIN_HEIGHT) + { + m_region_msg->resize(m_region_msg->mx, --crawl_view.msgsz.y); + } - m_region_stat->place(stat_col, 0, 0); + if (m_region_tile->wy + m_region_msg->wy > m_windowsz.y) + { + m_region_tile->place(0, 0, 0); + m_region_msg->place(0, 0, 0); + message_overlay = true; + } + } + + if (message_overlay) + { + m_region_msg->resize_to_fit(m_region_tile->ex, m_region_msg->ey); + crawl_view.msgsz.x = m_region_msg->mx; + crawl_view.msgsz.y = m_region_msg->my; + } + else + { + m_region_msg->resize_to_fit(m_region_msg->wx, + m_windowsz.y - m_region_msg->sx); + int msg_y = std::min(Options.msg_max_height, (int)m_region_msg->my); + m_region_msg->resize(m_region_msg->mx, msg_y); + } + m_region_msg->set_overlay(message_overlay); + + // Shrink view width if stat window can't fit... + int stat_col; + crawl_view.viewsz.x += 2; + do + { + crawl_view.viewsz.x -= 2; + m_region_tile->mx = crawl_view.viewsz.x; + m_region_tile->place(0, 0, margin); + + stat_col = m_region_tile->ex + map_stat_buffer; + m_region_stat->place(stat_col, 0, 0); + m_region_stat->resize_to_fit(m_windowsz.x - m_region_stat->sx, + m_region_stat->wy); + } + while (m_region_stat->ex > m_windowsz.x + && crawl_view.viewsz.x > VIEW_MIN_WIDTH); + + int hud_width = std::min(50, (int)m_region_stat->mx); + m_region_stat->resize(hud_width, m_region_stat->my); + crawl_view.hudsz.x = m_region_stat->mx; + crawl_view.hudsz.y = m_region_stat->my; + + // Resize map to fit the screen + m_region_map->dx = m_region_map->dy = Options.tile_map_pixels; m_region_map->place(stat_col, m_region_stat->ey, map_margin); + while (m_region_map->ex > m_windowsz.x) + { + m_region_map->dx--; + m_region_map->dy--; + m_region_map->resize(GXM, GYM); + } int inv_col = std::max(m_region_tile->ex, m_region_msg->ex); + if (message_overlay) + inv_col = stat_col; m_region_self_inv->place(inv_col, m_region_map->ey, 0); m_region_self_inv->resize_to_fit(m_windowsz.x - - m_region_self_inv->sx, - m_windowsz.y - - m_region_self_inv->sy); + m_region_self_inv->sx, + m_windowsz.y - + m_region_self_inv->sy); + m_region_self_inv->resize(std::min(13, (int)m_region_self_inv->mx), + std::min(6, (int)m_region_self_inv->my)); + + int self_inv_y = m_windowsz.y - m_region_self_inv->wy - margin; + m_region_self_inv->place(inv_col, self_inv_y, 0); + + // recenter map above inventory + int map_cen_x = m_region_self_inv->sx + (m_region_self_inv->wx) / 2; + m_region_map->place(map_cen_x - m_region_map->wy / 2, m_region_map->sy, + map_margin); // Place regions for crt layer m_region_crt->place(0, 0, margin); + + while (m_region_crt->ey + m_region_menu_inv->wy > m_windowsz.y) + { + m_region_crt->resize(m_region_crt->mx, m_region_crt->my - 1); + } + while (m_region_crt->ex > m_windowsz.x) + { + m_region_crt->resize(m_region_crt->mx - 1, m_region_crt->my); + } + m_region_menu_inv->place(0, m_region_crt->ey, margin); m_region_menu_inv->resize_to_fit(m_windowsz.x, m_windowsz.y - - m_region_menu_inv->sy); + m_region_menu_inv->sy); + + // Depending on the font, the menu inventory may hold fewer items + // than the crt menu can display. Decrease the lines if necessary. + const int ex = 3; + if (m_region_crt->my - ex > m_region_menu_inv->mx) + m_region_crt->resize(m_region_crt->mx, m_region_menu_inv->mx + ex); + + crawl_view.init_view(); } void TilesFramework::clrscr() @@ -723,6 +851,18 @@ void TilesFramework::clear_message_window() m_active_layer = LAYER_NORMAL; } +int TilesFramework::get_number_of_lines() +{ + return m_region_crt->my; +} + +int TilesFramework::get_number_of_cols() +{ + // TODO enne - do we need to differentiate the number of columns + // in the message window and the number of columns on the CRT? + return m_region_crt->mx; +} + void TilesFramework::cgotoxy(int x, int y, int region) { if (region == GOTO_LAST) @@ -884,6 +1024,12 @@ void TilesFramework::update_inventory() // TODO enne - if all inventory and ground can't fit, allow ground // and inventory items on the same row. + // TODO enne - if inventory fills up all squares, add up to one row + // of ground, depending. + + // TODO enne - only fill up 52 squares of inventory, then start + // showing floor. + // item.base_type <-> char conversion table const static char *obj_syms = ")([/%#?=!#+\\0}x"; diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h index 5bfe1e998e..ff7cd37df8 100644 --- a/crawl-ref/source/tilesdl.h +++ b/crawl-ref/source/tilesdl.h @@ -97,6 +97,8 @@ public: 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); + int get_number_of_lines(); + int get_number_of_cols(); void clear_message_window(); void update_minimap(int gx, int gy); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b552a49215..1500009a16 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -5149,7 +5149,7 @@ void crawl_view_buffer::size(const coord_def &sz) // define VIEW_MAX_WIDTH use Options.view_max_width #define HUD_WIDTH 42 #define HUD_HEIGHT 12 -#define MSG_MIN_HEIGHT 7 +// #define MSG_MIN_HEIGHT defined elsewhere #define MSG_MAX_HEIGHT Options.msg_max_height #define MLIST_MIN_HEIGHT Options.mlist_min_height #define MLIST_MIN_WIDTH 25 // non-inline layout only @@ -5369,6 +5369,8 @@ crawl_view_geometry::crawl_view_geometry() void crawl_view_geometry::init_view() { + viewhalfsz = viewsz / 2; + vbuf.size(viewsz); set_player_at(you.pos(), true); } @@ -5471,8 +5473,6 @@ void crawl_view_geometry::init_geometry() gui_init_view_params(*this); #endif - viewhalfsz = viewsz / 2; - vbuf.size(viewsz); init_view(); return; } |