Skip to content

Commit

Permalink
draw the overmap with SDL using sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Aug 26, 2020
1 parent df4a02e commit 2177f99
Show file tree
Hide file tree
Showing 11 changed files with 534 additions and 66 deletions.
21 changes: 21 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,20 @@
"//": "separate entry, because the global entry also has 'q' and 'Q' listed, which conflicts with the world name entry feature of this dialog",
"bindings": [ { "input_method": "keyboard_any", "key": "ESC" } ]
},
{
"type": "keybinding",
"id": "ZOOM_OUT",
"category": "OVERMAP",
"name": "Zoom Out",
"bindings": [ { "input_method": "keyboard_char", "key": "Z" }, { "input_method": "keyboard_code", "key": "z", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "ZOOM_IN",
"category": "OVERMAP",
"name": "Zoom In",
"bindings": [ { "input_method": "keyboard_any", "key": "z" } ]
},
{
"type": "keybinding",
"id": "DELETE_NOTE",
Expand Down Expand Up @@ -927,6 +941,13 @@
"name": "Toggle Hordes",
"bindings": [ { "input_method": "keyboard_char", "key": "H" }, { "input_method": "keyboard_code", "key": "h", "mod": [ "shift" ] } ]
},
{
"type": "keybinding",
"id": "TOGGLE_OVERMAP_WEATHER",
"category": "OVERMAP",
"name" :"Toggle Visible Weather",
"bindings": [ { "input_method": "keyboard_any", "key": "w" } ]
},
{
"type": "keybinding",
"id": "TOGGLE_FOREST_TRAILS",
Expand Down
26 changes: 12 additions & 14 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static const std::array<std::string, 8> multitile_keys = {{
extern int fontwidth;
extern int fontheight;
static const std::string empty_string;
static const std::array<std::string, 12> TILE_CATEGORY_IDS = {{
static const std::array<std::string, 13> TILE_CATEGORY_IDS = {{
"", // C_NONE,
"vehicle_part", // C_VEHICLE_PART,
"terrain", // C_TERRAIN,
Expand All @@ -105,6 +105,7 @@ static const std::array<std::string, 12> TILE_CATEGORY_IDS = {{
"bullet", // C_BULLET,
"hit_entity", // C_HIT_ENTITY,
"weather", // C_WEATHER,
"overmap_terrain"
}
};

Expand Down Expand Up @@ -977,19 +978,6 @@ void tileset_loader::load_tile_spritelists( const JsonObject &entry,
}
}

struct tile_render_info {
const tripoint pos{};
// accumulator for 3d tallness of sprites rendered here so far;
int height_3d = 0;
lit_level ll;
bool invisible[5];
tile_render_info( const tripoint &pos, const int height_3d, const lit_level ll,
const bool ( &invisible )[5] )
: pos( pos ), height_3d( height_3d ), ll( ll ) {
std::copy( invisible, invisible + 5, this->invisible );
}
};

void cata_tiles::draw( const point &dest, const tripoint &center, int width, int height,
std::multimap<point, formatted_text> &overlay_strings,
color_block_overlay_container &color_blocks )
Expand Down Expand Up @@ -1710,6 +1698,15 @@ bool cata_tiles::draw_from_id_string( std::string id, TILE_CATEGORY category,
}
sym = tmp.symbol().empty() ? ' ' : tmp.symbol().front();
col = tmp.color();
} else if( category == C_OVERMAP_TERRAIN ) {
const oter_str_id tmp( id );
if( tmp.is_valid() ) {
sym = tmp->get_symbol().front();
col = tmp->get_color();
}
} else if( category == C_OVERMAP_NOTE ) {
sym = id[5];
col = color_from_string( id.substr( 7, id.length() - 1 ) );
}
// Special cases for walls
switch( sym ) {
Expand Down Expand Up @@ -1881,6 +1878,7 @@ bool cata_tiles::draw_from_id_string( std::string id, TILE_CATEGORY category,
case C_BULLET:
case C_HIT_ENTITY:
case C_WEATHER:
case C_OVERMAP_TERRAIN:
// TODO: come up with ways to make random sprites consistent for these types
break;
case C_MONSTER:
Expand Down
18 changes: 18 additions & 0 deletions src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ enum TILE_CATEGORY {
C_BULLET,
C_HIT_ENTITY,
C_WEATHER,
C_OVERMAP_TERRAIN,
C_OVERMAP_NOTE
};

class texture
Expand Down Expand Up @@ -281,6 +283,7 @@ class cata_tiles
void draw( const point &dest, const tripoint &center, int width, int height,
std::multimap<point, formatted_text> &overlay_strings,
color_block_overlay_container &color_blocks );
void draw_om( const point &dest, const tripoint_abs_omt &center_abs_omt, bool blink );

/** Minimap functionality */
void draw_minimap( const point &dest, const tripoint &center, int width, int height );
Expand Down Expand Up @@ -484,6 +487,8 @@ class cata_tiles
point player_to_screen( const point & ) const;
static std::vector<options_manager::id_and_option> build_renderer_list();
static std::vector<options_manager::id_and_option> build_display_list();
private:
int get_omt_rotation( std::string &id );
protected:
template <typename maptype>
void tile_loading_report( const maptype &tiletypemap, TILE_CATEGORY category,
Expand Down Expand Up @@ -589,4 +594,17 @@ class cata_tiles
std::string memory_map_mode = "color_pixel_sepia";
};

struct tile_render_info {
const tripoint pos{};
// accumulator for 3d tallness of sprites rendered here so far;
int height_3d = 0;
lit_level ll;
bool invisible[5];
tile_render_info( const tripoint &pos, const int height_3d, const lit_level ll,
const bool( &invisible )[5] )
: pos( pos ), height_3d( height_3d ), ll( ll ) {
std::copy( invisible, invisible + 5, this->invisible );
}
};

#endif // CATA_SRC_CATA_TILES_H
1 change: 1 addition & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "pimpl.h"
#include "point.h"
#include "type_id.h"
#include "uistate.h"
#include "weather.h"

class Character;
Expand Down
Loading

0 comments on commit 2177f99

Please sign in to comment.