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 "lisp/li_init.hh"
|
---|
10 | #include "m1_info.hh"
|
---|
11 | #include "max_object.hh"
|
---|
12 | #include "render.hh"
|
---|
13 | #include "st_edit.hh"
|
---|
14 | #include "app/app.hh"
|
---|
15 |
|
---|
16 | class m1_drag_select_class : public m1_utility_state_class
|
---|
17 | {
|
---|
18 | public:
|
---|
19 | i4_float ax,ay;
|
---|
20 | i4_float px,py;
|
---|
21 |
|
---|
22 | virtual i4_bool mouse_down()
|
---|
23 | {
|
---|
24 | ax = mouse_x();
|
---|
25 | ay = mouse_y();
|
---|
26 |
|
---|
27 | return i4_F;
|
---|
28 | }
|
---|
29 |
|
---|
30 | virtual i4_bool mouse_up()
|
---|
31 | {
|
---|
32 | g1_quad_object_class *obj = m1_info.obj;
|
---|
33 | g1_vert_class *src_vert = obj->get_verts(m1_info.current_animation, m1_info.current_frame);
|
---|
34 | r1_vert v;
|
---|
35 | i4_float tmp;
|
---|
36 |
|
---|
37 | px = mouse_x();
|
---|
38 | py = mouse_y();
|
---|
39 |
|
---|
40 | if (ax>px) { tmp=ax; ax=px; px=tmp; }
|
---|
41 | if (ay>py) { tmp=ay; ay=py; py=tmp; }
|
---|
42 |
|
---|
43 | if (!i4_current_app->get_window_manager()->shift_pressed())
|
---|
44 | li_call("select_none");
|
---|
45 |
|
---|
46 | for (int i=0; i<obj->num_quad; i++)
|
---|
47 | {
|
---|
48 | g1_quad_class *q = &obj->quad[i];
|
---|
49 | i4_bool out=i4_F;
|
---|
50 | for (int j=0; j<q->num_verts() && !out; j++)
|
---|
51 | {
|
---|
52 | m1_render_window->project_point(src_vert[q->vertex_ref[j]].v, v);
|
---|
53 | if (v.px<ax || v.px>px || v.py<ay || v.py>py)
|
---|
54 | out = i4_T;
|
---|
55 | }
|
---|
56 | if (!out)
|
---|
57 | q->set_flags(g1_quad_class::SELECTED);
|
---|
58 | }
|
---|
59 | m1_render_window->restore_state();
|
---|
60 | m1_render_window->request_redraw(i4_F);
|
---|
61 | m1_st_edit->edit_poly_changed();
|
---|
62 |
|
---|
63 | return i4_T;
|
---|
64 | }
|
---|
65 |
|
---|
66 | virtual i4_bool mouse_drag()
|
---|
67 | {
|
---|
68 | return i4_F;
|
---|
69 | }
|
---|
70 | };
|
---|
71 |
|
---|
72 | static m1_drag_select_class drag_select;
|
---|
73 |
|
---|
74 | li_object *m1_drag_select(li_object *o, li_environment *env)
|
---|
75 | {
|
---|
76 | if (m1_info.obj)
|
---|
77 | m1_render_window->set_state(&drag_select);
|
---|
78 |
|
---|
79 | return 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | li_automatic_add_function(m1_drag_select, "drag_select");
|
---|