From 4bc8fa481841a89bd2b6880f7570824478048ca1 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Thu, 24 Jul 2008 01:41:54 +0000 Subject: Moving more settings to the Tiles options file. Fixing a mouse-related crash that Johanna mentioned. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6657 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/externs.h | 8 +++++--- crawl-ref/source/initfile.cc | 18 +++++++++++------- crawl-ref/source/tilereg.cc | 5 +++-- crawl-ref/source/tilesdl.cc | 18 ++++++++---------- crawl-ref/source/tiletex.cc | 17 ++++++++++++----- 5 files changed, 39 insertions(+), 27 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index ceac4828d0..c1734d0aa6 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1892,9 +1892,11 @@ public: int tile_font_lbl_size; std::string tile_font_tip_file; int tile_font_tip_size; -#endif -#ifdef WIN32TILES - bool use_dos_char; + bool tile_full_screen; + int tile_window_width; + int tile_window_height; + int tile_map_pixels; + int tile_tooltip_ms; #endif typedef std::map opt_map; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 0b1594d947..55e6e64aac 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -863,10 +863,13 @@ void game_options::reset_options() tile_font_tip_size = 15; tile_font_lbl_file = "Vera.ttf"; tile_font_lbl_size = 14; -#endif -#ifdef WIN32TILES - use_dos_char = true; + // window layout + tile_full_screen = false; + tile_window_width = 1024; + tile_window_height = 768; + tile_map_pixels = 4; + tile_tooltip_ms = 1000; #endif // map each colour to itself as default @@ -2980,10 +2983,11 @@ void game_options::read_option_line(const std::string &str, bool runscript) tile_font_lbl_file = field; } else INT_OPTION(tile_font_lbl_size, 1, INT_MAX); -#endif - -#ifdef WIN32TILES - else BOOL_OPTION(use_dos_char); + else BOOL_OPTION(tile_full_screen); + else INT_OPTION(tile_window_width, 1, INT_MAX); + else INT_OPTION(tile_window_height, 1, INT_MAX); + else INT_OPTION(tile_map_pixels, 1, INT_MAX); + else INT_OPTION(tile_tooltip_ms, 0, INT_MAX); #endif else if(key == "bindkey") diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 0fff45c4d7..8338c64f81 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -1487,8 +1487,6 @@ int InventoryRegion::handle_mouse(MouseEvent &event) if (event.event != MouseEvent::PRESS) return 0; - // TODO enne - if mouse_mode is command, then: - unsigned int item_idx = cursor_index(); if (item_idx >= m_items.size() || m_items[item_idx].empty()) return 0; @@ -1589,6 +1587,9 @@ static bool _can_use_item(const item_def &item, bool equipped) bool InventoryRegion::update_tip_text(std::string& tip) { + if (m_cursor == NO_CURSOR) + return false; + unsigned int item_idx = cursor_index(); if (item_idx >= m_items.size() || m_items[item_idx].empty()) return false; diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index df3f7b7d34..a78f6bbf60 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -148,10 +148,12 @@ bool TilesFramework::initialise() SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); unsigned int flags = SDL_OPENGL; - if (m_fullscreen) + if (Options.tile_full_screen) flags |= SDL_FULLSCREEN; - // TODO enne - add options for screen size and fullscreen + m_windowsz.x = Options.tile_window_width; + m_windowsz.y = Options.tile_window_height; + m_context = SDL_SetVideoMode(m_windowsz.x, m_windowsz.y, 0, flags); if (!m_context) { @@ -162,9 +164,6 @@ bool TilesFramework::initialise() if (!m_image.load_textures()) return false; - // TODO enne - grab these from options - unsigned int map_pixsz = 4; - int crt_font = load_font(Options.tile_font_crt_file.c_str(), Options.tile_font_crt_size); int msg_font = load_font(Options.tile_font_msg_file.c_str(), @@ -184,7 +183,7 @@ bool TilesFramework::initialise() m_region_tile = new DungeonRegion(&m_image, m_fonts[lbl_font].font, TILE_X, TILE_Y); - m_region_map = new MapRegion(map_pixsz); + m_region_map = new MapRegion(Options.tile_map_pixels); m_region_self_inv = new InventoryRegion(&m_image, TILE_X, TILE_Y); m_region_msg = new MessageRegion(m_fonts[msg_font].font); @@ -581,10 +580,9 @@ int TilesFramework::getch_ck() } } - // TODO enne - outsource this value - unsigned int tooltip_ticks = 1000; - bool show_tooltip = ((ticks - m_last_tick_moved > tooltip_ticks) - && ticks > m_last_tick_moved); + bool show_tooltip = + ((ticks - m_last_tick_moved > Options.tile_tooltip_ms) + && ticks > m_last_tick_moved); if (show_tooltip) { diff --git a/crawl-ref/source/tiletex.cc b/crawl-ref/source/tiletex.cc index 38c2aa729a..f289352656 100644 --- a/crawl-ref/source/tiletex.cc +++ b/crawl-ref/source/tiletex.cc @@ -1,5 +1,6 @@ #include "AppHdr.h" +#include "files.h" #include "tiles.h" #include "tiletex.h" @@ -29,14 +30,20 @@ bool GenericTexture::load_texture(const char *filename, tex_proc_func proc) { char acBuffer[512]; - // TODO enne - use Crawl's helper functions to find images... - strcpy(acBuffer, "dat/tiles/"); - strcat(acBuffer, filename); - SDL_Surface *img = IMG_Load(acBuffer); + + std::string tex_path = datafile_path(filename); + + if (tex_path.c_str()[0] == 0) + { + fprintf(stderr, "Couldn't find texture '%s'.\n", filename); + return false; + } + + SDL_Surface *img = IMG_Load(tex_path.c_str()); if (!img) { - printf("Warning: couldn't load file '%s'.\n", acBuffer); + fprintf(stderr, "Couldn't load texture '%s'.\n", tex_path.c_str()); return false; } -- cgit v1.2.3-54-g00ecf