1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "editor/dialogs/tile_win.hh"
|
---|
10 | #include "obj3d.hh"
|
---|
11 | #include "math/pi.hh"
|
---|
12 | #include "image/image.hh"
|
---|
13 | #include "draw_context.hh"
|
---|
14 | #include "window/win_evt.hh"
|
---|
15 | #include "device/kernel.hh"
|
---|
16 | #include "image/color.hh"
|
---|
17 | #include "r1_api.hh"
|
---|
18 | #include "editor/e_state.hh"
|
---|
19 | #include "tile.hh"
|
---|
20 | #include "map_vert.hh"
|
---|
21 | #include "map_cell.hh"
|
---|
22 | #include "g1_render.hh"
|
---|
23 | #include "editor/mode/e_tile.hh"
|
---|
24 | #include "resources.hh"
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | g1_3d_tile_window::g1_3d_tile_window(w16 w, w16 h,
|
---|
29 | int tile_num,
|
---|
30 | g1_3d_pick_window::camera_struct &camera,
|
---|
31 | i4_image_class *active_back,
|
---|
32 | i4_image_class *passive_back,
|
---|
33 | i4_event_reaction_class *reaction)
|
---|
34 | : g1_3d_pick_window(w,h,
|
---|
35 | active_back, passive_back,
|
---|
36 | camera,
|
---|
37 | reaction),
|
---|
38 | object(object),
|
---|
39 | tile_num(tile_num)
|
---|
40 |
|
---|
41 | {
|
---|
42 | w32 min_screen = w<h ? w : h;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | inline void g1_setup_vert(r1_vert *v, float px, float py, float z)
|
---|
47 | {
|
---|
48 | v->px=px;
|
---|
49 | v->py=py;
|
---|
50 | v->v.z=z;
|
---|
51 | v->w=1.0/z;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void g1_3d_tile_window::do_press()
|
---|
55 | {
|
---|
56 | if (tile_num<g1_tile_man.remap_size())
|
---|
57 | {
|
---|
58 | g1_e_tile.set_cell_type(g1_tile_man.get_remap(tile_num));
|
---|
59 |
|
---|
60 | if (strcmp(g1_edit_state.major_mode,"TILE"))
|
---|
61 | g1_edit_state.set_major_mode("TILE");
|
---|
62 |
|
---|
63 | if (g1_e_tile.get_minor_mode() != g1_tile_params::PLACE)
|
---|
64 | g1_edit_state.set_minor_mode("TILE",g1_tile_params::PLACE);
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | i4_bool g1_3d_tile_window::selected()
|
---|
69 | {
|
---|
70 | if (tile_num==g1_e_tile.get_cell_type())
|
---|
71 | return i4_T;
|
---|
72 | else
|
---|
73 | return i4_F;
|
---|
74 | }
|
---|
75 |
|
---|
76 | void g1_3d_tile_window::draw_object(g1_draw_context_class *context)
|
---|
77 | {
|
---|
78 | if (tile_num<g1_tile_man.remap_size())
|
---|
79 | {
|
---|
80 | r1_texture_handle han=g1_tile_man.get_texture(g1_tile_man.get_remap(tile_num));
|
---|
81 | r1_render_api_class *render_api=g1_render.r_api;
|
---|
82 |
|
---|
83 | if (active)
|
---|
84 | render_api->set_constant_color(0xffffff);
|
---|
85 | else
|
---|
86 | render_api->set_constant_color(0x9f9f9f);
|
---|
87 |
|
---|
88 | if (tile_num<g1_tile_man.remap_size())
|
---|
89 | {
|
---|
90 | render_api->use_texture(han, width(), 0);
|
---|
91 |
|
---|
92 | r1_vert v1[3],v2[3];
|
---|
93 | g1_setup_tri_texture_coords(v1, v2, g1_e_tile.get_cell_rotation(), g1_e_tile.get_mirrored());
|
---|
94 |
|
---|
95 | g1_setup_vert(v1, 0, height()-1, 50);
|
---|
96 | g1_setup_vert(v1+1, width()-1,height()-1, 50);
|
---|
97 | g1_setup_vert(v1+2, width()-1,0, 50);
|
---|
98 |
|
---|
99 | render_api->render_poly(3, v1);
|
---|
100 |
|
---|
101 | g1_setup_vert(v2, 0, height()-1, 50);
|
---|
102 | g1_setup_vert(v2+1, width()-1, 0, 50);
|
---|
103 | g1_setup_vert(v2+2, 0, 0, 50);
|
---|
104 |
|
---|
105 | render_api->render_poly(3, v2);
|
---|
106 | }
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 |
|
---|