Skip to content

Commit 83b0bd2

Browse files
author
s.kushnirenko
committed
temples: moved animation config to js
1 parent 2531eeb commit 83b0bd2

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

src/building/building_temple.cpp

+61
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,48 @@
1313
#include "window/building/common.h"
1414
#include "window/building/figures.h"
1515
#include "sound/sound_building.h"
16+
#include "graphics/animation.h"
1617
#include "game/game.h"
18+
#include "city/labor.h"
19+
#include "widget/city/ornaments.h"
20+
21+
namespace model {
22+
23+
struct building_temple_t {
24+
const e_building_type type;
25+
const pcstr name;
26+
bstring64 meta_id;
27+
e_labor_category labor_category;
28+
animations_t anim;
29+
};
30+
31+
building_temple_t temple_osiris{BUILDING_TEMPLE_OSIRIS, "building_temple_osiris"};
32+
building_temple_t temple_ra{BUILDING_TEMPLE_RA, "building_temple_ra"};
33+
building_temple_t temple_ptah{BUILDING_TEMPLE_PTAH, "building_temple_ptah"};
34+
building_temple_t temple_seth{BUILDING_TEMPLE_SETH, "building_temple_seth"};
35+
building_temple_t temple_bast{BUILDING_TEMPLE_BAST, "building_temple_bast"};
36+
building_temple_t temple_dummy{BUILDING_NONE, "unknown"};
37+
38+
}
39+
40+
ANK_REGISTER_CONFIG_ITERATOR(config_load_building_temples);
41+
void config_load_building_temples() {
42+
auto load_temple_model = [] (model::building_temple_t &model) {
43+
g_config_arch.r_section(model.name, [&model] (archive arch) {
44+
model.labor_category = arch.r_type<e_labor_category>("labor_category");
45+
model.meta_id = arch.r_string("meta_id");
46+
model.anim.load(arch);
47+
city_labor_set_category(model);
48+
});
49+
50+
};
51+
52+
load_temple_model(model::temple_osiris);
53+
load_temple_model(model::temple_ra);
54+
load_temple_model(model::temple_ptah);
55+
load_temple_model(model::temple_seth);
56+
load_temple_model(model::temple_bast);
57+
}
1758

1859
static void building_temple_draw_temple(object_info& c, const char* type, int group_id, int image_offset) {
1960
c.help_id = 67;
@@ -83,3 +124,23 @@ void building_temple::spawn_figure() {
83124
common_spawn_roamer(FIGURE_PRIEST, 50, FIGURE_ACTION_125_ROAMING);
84125
}
85126
}
127+
128+
bool building_temple::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) {
129+
const animation_t &anim = params().anim["work"];
130+
building_draw_normal_anim(ctx, point, &base, tile, anim, color_mask);
131+
132+
return true;
133+
}
134+
135+
const model::building_temple_t &building_temple::params() const {
136+
switch (type()) {
137+
case BUILDING_TEMPLE_OSIRIS: return model::temple_osiris;
138+
case BUILDING_TEMPLE_RA: return model::temple_ra;
139+
case BUILDING_TEMPLE_PTAH: return model::temple_ptah;
140+
case BUILDING_TEMPLE_SETH: return model::temple_seth;
141+
case BUILDING_TEMPLE_BAST: return model::temple_bast;
142+
}
143+
144+
assert(false);
145+
return model::temple_dummy;
146+
}

src/building/building_temple.h

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

33
#include "building/building.h"
44

5+
namespace model {
6+
struct building_temple_t;
7+
}
8+
59
class building_temple : public building_impl {
610
public:
711
building_temple(building &b) : building_impl(b) {}
@@ -10,4 +14,6 @@ class building_temple : public building_impl {
1014
virtual e_sound_channel_city sound_channel() const override;
1115
virtual void window_info_background(object_info &c) override;
1216
virtual void spawn_figure() override;
17+
virtual bool draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color mask) override;
18+
const model::building_temple_t &params() const;
1319
};

src/scripts/building_info.js

+30
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,36 @@ building_personal_mansion = {
5959
}
6060
}
6161

62+
building_temple_osiris = {
63+
animations : {
64+
work : { pos : [-1, -1], anim_id: IMG_TEMPLE_OSIRIS }
65+
}
66+
}
67+
68+
building_temple_ra = {
69+
animations : {
70+
work : { pos : [-1, -1], anim_id: IMG_TEMPLE_RA }
71+
}
72+
}
73+
74+
building_temple_ptah = {
75+
animations : {
76+
work : { pos : [-1, -1], anim_id: IMG_TEMPLE_PTAH }
77+
}
78+
}
79+
80+
building_temple_seth = {
81+
animations : {
82+
work : { pos : [-1, -1], anim_id: IMG_TEMPLE_SETH }
83+
}
84+
}
85+
86+
building_temple_bast = {
87+
animations : {
88+
work : { pos : [-1, -1], anim_id: IMG_TEMPLE_BAST }
89+
}
90+
}
91+
6292
building_booth = {
6393
animations : {
6494
juggler : { pos : [35, 17], base_id : IMG_BOOTH, anim_id : IMG_JUGGLER_SHOW }

src/scripts/common.js

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ var medium_statue_images = []
2222
var big_statue_images = []
2323
var top_menu_bar = {}
2424
var main_menu_window = {}
25+
var building_temple_osiris = {}
26+
var building_temple_ra = {}
27+
var building_temple_ptah = {}
28+
var building_temple_seth = {}
29+
var building_temple_bast = {}
30+
var building_temple = {}
2531
var building_copper_mine = {}
2632
var building_gems_mine = {}
2733
var building_physician = {}

0 commit comments

Comments
 (0)