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 authored and kevingranade committed Jul 4, 2021
1 parent add6f7d commit 1d04305
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 65 deletions.
1 change: 0 additions & 1 deletion data/json/items/comestibles/veggy_dishes.json
Expand Up @@ -19,7 +19,6 @@
"copy-from": "cattail_rhizome",
"weight": "160 g",
"volume": "220 ml",
"milling": { "into": "flour", "conversion_rate": 7.5 },
"color": "black",
"calories": 280,
"spoils_in": "5 days",
Expand Down
21 changes: 21 additions & 0 deletions data/raw/keybindings.json
Expand Up @@ -858,6 +858,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 @@ -942,6 +956,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
15 changes: 13 additions & 2 deletions src/cata_tiles.cpp
Expand Up @@ -91,7 +91,7 @@ static const std::array<std::string, 8> multitile_keys = {{
};

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 @@ -104,6 +104,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 @@ -1048,7 +1049,7 @@ struct tile_render_info {
lit_level ll;
bool invisible[5];
tile_render_info( const tripoint &pos, const int height_3d, const lit_level ll,
const bool ( &invisible )[5] )
const bool( &invisible )[5] )
: pos( pos ), height_3d( height_3d ), ll( ll ) {
std::copy_n( invisible, 5, this->invisible );
}
Expand Down Expand Up @@ -1809,6 +1810,15 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ
}
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 @@ -1979,6 +1989,7 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ
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
5 changes: 5 additions & 0 deletions src/cata_tiles.h
Expand Up @@ -71,6 +71,8 @@ enum TILE_CATEGORY {
C_BULLET,
C_HIT_ENTITY,
C_WEATHER,
C_OVERMAP_TERRAIN,
C_OVERMAP_NOTE
};

class tile_lookup_res
Expand Down Expand Up @@ -320,6 +322,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 @@ -535,6 +538,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
1 change: 1 addition & 0 deletions src/game.h
Expand Up @@ -31,6 +31,7 @@
#include "pimpl.h"
#include "point.h"
#include "type_id.h"
#include "uistate.h"
#include "units_fwd.h"
#include "weather.h"

Expand Down

0 comments on commit 1d04305

Please sign in to comment.