1 /*****************************************************************************
2 *
3 * Copyright (C) 2003 C�dric Br�gardis <cedric.bregardis@free.fr>
4 *
5 * This file is part of BRIQUOLO
6 *
7 * BRIQUOLO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * BRIQUOLO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with BRIQUOLO; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 *****************************************************************************/
22 #include "I18n.h"
23 #include "PanneauOutilsEditeur.h"
24 #include "Gestionnaire.h"
25 #include "Constante.h"
26
PanneauOutilsEditeur(MOGL_Fenetre * p_Fenetre)27 PanneauOutilsEditeur::PanneauOutilsEditeur(MOGL_Fenetre * p_Fenetre): MOGL_Panneau(p_Fenetre, _("Tools"), 200, 110),
28 _Police(10), _Pause(false)
29 {
30 _AlignementHorizontal=MAX;
31 _AlignementVertical=MIN;
32
33 _Police.Charger((Constante::GetGlobalDir()+Constante::GetDataDir()+_("/DejaVuSans.ttf")).c_str());
34
35
36 SetPolice(&_Police);
37
38 _ChoixAction=new MOGL_Choix(this, _("Action"));
39 _ChoixAction->SetPolice(&_Police);
40 _ChoixAction->AjouterElementChoix(_("Add"));
41 _ChoixAction->AjouterElementChoix(_("Edit/Delete"));
42
43 _ChoixElement=new MOGL_Choix(this, _("Element"));
44 _ChoixElement->SetPolice(&_Police);
45 for(unsigned int i=0; i<Gestionnaire::GetNombreElementTableau(); i++)
46 {
47 _ChoixElement->AjouterElementChoix(Gestionnaire::GetNomElementTableau(i));
48 }
49
50 _ChoixVariation=new MOGL_Choix(this, _("Variation"));
51 _ChoixVariation->SetPolice(&_Police);
52 _ChoixVariation->ChangementElement.Connecter(this, &PanneauOutilsEditeur::_OnChangementVariation);
53 _ChoixVariation->AjouterElementChoix(_("Custom"));
54 _ChoixVariation->AjouterElementChoix(_("Brick"));
55 _ChoixVariation->AjouterElementChoix(_("Small brick"));
56
57 _VariationX=new MOGL_ChoixNombre(this, _(" X variation"), 0.1f, 0.05f);
58 _VariationX->SetPolice(&_Police);
59
60 _VariationY=new MOGL_ChoixNombre(this, _(" Y variation"), 0.1f, 0.05f);
61 _VariationY->SetPolice(&_Police);
62
63 _LabelSup = new MOGL_Label(this, STACKED_BRICK);
64 _LabelSup->SetPolice(&_Police);
65 _LabelSup->SetCacher(true);
66
67 _ChoixVariation->SetIndiceCourant(1);
68
69 SetUtiliserEscape(false);
70
71 p_Fenetre->ChangementMode.Connecter(this, &PanneauOutilsEditeur::_OnChangementResolution);
72 }
73
GetVariationX() const74 float PanneauOutilsEditeur::GetVariationX() const
75 {
76 if (_ChoixVariation->GetIndiceCourant()==0)
77 {
78 return _VariationX->GetNombre();
79 }
80 else
81 {
82 return _VarX;
83 }
84 }
85
GetVariationY() const86 float PanneauOutilsEditeur::GetVariationY() const
87 {
88 if (_ChoixVariation->GetIndiceCourant()==0)
89 {
90 return _VariationY->GetNombre();
91 }
92 else
93 {
94 return _VarY;
95 }
96 }
97
GetIdentifiantElement()98 unsigned int PanneauOutilsEditeur::GetIdentifiantElement()
99 {
100 return _ChoixElement->GetIndiceCourant();
101 }
102
SetPause(bool p_Pause)103 void PanneauOutilsEditeur::SetPause(bool p_Pause)
104 {
105 _Pause=p_Pause;
106 }
107
GetPause() const108 bool PanneauOutilsEditeur::GetPause() const
109 {
110 return _Pause;
111 }
112
ClavierUp(SDL_keysym * key)113 void PanneauOutilsEditeur::ClavierUp(SDL_keysym * key)
114 {
115 if (!_Pause)
116 {
117 MOGL_Panneau::ClavierUp(key);
118 }
119 }
120
_OnChangementResolution(int p_ResolutionX,int p_ResolutionY,int p_BitParPixel)121 void PanneauOutilsEditeur::_OnChangementResolution(int p_ResolutionX, int p_ResolutionY, int p_BitParPixel)
122 {
123 _Police.Recharger();
124 }
125
126
_OnChangementVariation(unsigned int p_Indice)127 void PanneauOutilsEditeur::_OnChangementVariation(unsigned int p_Indice)
128 {
129 if (p_Indice==0)
130 {
131 _VariationX->SetCacher(false);
132 _VariationY->SetCacher(false);
133 }
134 else
135 {
136 _VariationX->SetCacher(true);
137 _VariationY->SetCacher(true);
138 }
139 switch(p_Indice)
140 {
141 case 1:
142 {
143 _VarX=3.5;
144 _VarY=2.5;
145 break;
146 }
147 case 2:
148 {
149 _VarX=1.75;
150 _VarY=1.25;
151 break;
152 }
153 }
154 }
155