Skip to content

Commit 710f7c3

Browse files
author
s.kushnirenko
committed
feat add support for building_mansion
what: + remove unused function window_building_draw_governor_home + remove mansion building types from building_type_to_channel
1 parent d75d7ef commit 710f7c3

9 files changed

+36
-22
lines changed

src/building/building.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "building/building_pottery.h"
1919
#include "building/building_well.h"
2020
#include "building/building_shrine.h"
21+
#include "building/building_mansion.h"
2122
#include "city/buildings.h"
2223
#include "city/population.h"
2324
#include "city/warning.h"
@@ -341,6 +342,12 @@ building_impl *building::dcast() {
341342
case BUILDING_SHRINE_BAST:
342343
_ptr = new building_shrine(*this);
343344
break;
345+
346+
case BUILDING_PERSONAL_MANSION:
347+
case BUILDING_FAMILY_MANSION:
348+
case BUILDING_DYNASTY_MANSION:
349+
_ptr = new building_mansion(*this);
350+
break;
344351

345352
case BUILDING_SMALL_MASTABA:
346353
case BUILDING_SMALL_MASTABA_SIDE:

src/building/building.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "figure/figure_type.h"
1111
#include "game/resource.h"
1212
#include "grid/point.h"
13+
#include "sound/city.h"
1314

1415
#include <stdint.h>
1516
#include <algorithm>
@@ -390,6 +391,7 @@ class building_impl {
390391
virtual bool draw_ornaments_and_animations_height(vec2i point, tile2i tile, painter &ctx);
391392
virtual e_overlay get_overlay() const { return OVERLAY_NONE; }
392393
virtual bool need_road_access() const { return true; }
394+
virtual e_sound_channel_city sound_channel() const { return SOUND_CHANNEL_CITY_NONE; }
393395

394396
inline bool is_main() { return base.is_main(); }
395397
inline figure *create_roaming_figure(e_figure_type _type, e_figure_action created_action, e_building_slot slot) { return base.create_roaming_figure(_type, created_action, slot); }
@@ -398,7 +400,6 @@ class building_impl {
398400
inline tile2i tile() const { return base.tile; }
399401
inline e_building_type type() const { return base.type; }
400402

401-
402403
building &base;
403404
building::impl_data_t &data;
404405
};

src/building/building_mansion.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "building_mansion.h"
2+
3+
#include "window/building/common.h"
4+
#include "graphics/elements/panel.h"
5+
#include "graphics/elements/lang_text.h"
6+
7+
void building_mansion::window_info_background(object_info &c) {
8+
c.help_id = 78;
9+
window_building_play_sound(&c, "wavs/gov_palace.wav");
10+
outer_panel_draw(c.offset, c.width_blocks, c.height_blocks);
11+
lang_text_draw_centered(103, 0, c.offset.x, c.offset.y + 10, 16 * c.width_blocks, FONT_LARGE_BLACK_ON_LIGHT);
12+
window_building_draw_description_at(c, 16 * c.height_blocks - 143, 103, 1);
13+
}

src/building/building_mansion.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#include "building/building.h"
4+
5+
class building_mansion : public building_impl {
6+
public:
7+
building_mansion(building &b) : building_impl(b) {}
8+
virtual void window_info_background(object_info &ctx) override;
9+
virtual e_sound_channel_city sound_channel() const override { return SOUND_CHANNEL_CITY_MANSION; }
10+
};

src/sound/city.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ int building_type_to_channel(building *b) {
126126

127127
case BUILDING_FISHING_WHARF: return SOUND_CHANNEL_CITY_WHARF;
128128

129-
case BUILDING_PERSONAL_MANSION:
130-
case BUILDING_FAMILY_MANSION:
131-
case BUILDING_DYNASTY_MANSION:
132-
return SOUND_CHANNEL_CITY_MANSION;
133-
134129
case BUILDING_ARCHITECT_POST: return SOUND_CHANNEL_CITY_ENGINEERS_POST;
135130

136131
case BUILDING_LOW_BRIDGE:
@@ -168,7 +163,7 @@ int building_type_to_channel(building *b) {
168163
case BUILDING_HUNTING_LODGE: return SOUND_CHANNEL_CITY_HUNTER_LOUDGE;
169164
}
170165

171-
return 0;
166+
return b->dcast()->sound_channel();
172167
}
173168

174169
void sound_city_mark_terrain_view(int terrain, int grid_offset, int direction) {

src/sound/city.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum e_sound_dir {
1414
};
1515

1616
enum e_sound_channel_city {
17+
SOUND_CHANNEL_CITY_NONE = 0,
1718
SOUND_CHANNEL_CITY_START = SOUND_CHANNEL_CITY_MIN,
1819
SOUND_CHANNEL_CITY_HOUSE_SLUM = SOUND_CHANNEL_CITY_MIN,
1920
SOUND_CHANNEL_CITY_HOUSE_POOR,

src/window/building/government.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
#include "window/building/figures.h"
1111
#include "window/building/common.h"
1212

13-
void window_building_draw_governor_home(object_info* c) {
14-
c->help_id = 78;
15-
window_building_play_sound(c, "wavs/gov_palace.wav");
16-
outer_panel_draw(c->offset, c->width_blocks, c->height_blocks);
17-
lang_text_draw_centered(103, 0, c->offset.x, c->offset.y + 10, 16 * c->width_blocks, FONT_LARGE_BLACK_ON_LIGHT);
18-
window_building_draw_description_at(c, 16 * c->height_blocks - 143, 103, 1);
19-
}
20-
2113
void window_building_draw_triumphal_arch(object_info* c) {
2214
c->help_id = 79;
2315
window_building_play_sound(c, "wavs/statue.wav");

src/window/building/government.h

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
struct object_info;
44

5-
void window_building_draw_governor_home(object_info* c);
65
void window_building_draw_triumphal_arch(object_info* c);
76
void window_building_draw_courthouse(object_info* c);

src/window/window_building_info.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,8 @@ static void draw_refresh_background() {
687687
building_temple_bast_draw_info(context);
688688
break;
689689

690-
case BUILDING_ORACLE: window_building_draw_oracle(&context); break;
691-
692-
case BUILDING_PERSONAL_MANSION:
693-
case BUILDING_FAMILY_MANSION:
694-
case BUILDING_DYNASTY_MANSION:
695-
window_building_draw_governor_home(&context);
690+
case BUILDING_ORACLE:
691+
window_building_draw_oracle(&context);
696692
break;
697693

698694
case BUILDING_TAX_COLLECTOR:

0 commit comments

Comments
 (0)