Public Member Functions | |
uMenuItemInput (uMenu *M, uAction *a, int p) | |
virtual | ~uMenuItemInput () |
virtual void | Render (REAL x, REAL y, REAL alpha=1, bool selected=0) |
virtual void | Enter () |
virtual bool | Event (SDL_Event &e) |
virtual tString | Help () |
Private Attributes | |
uAction * | act |
int | ePlayer |
bool | active |
Definition at line 1063 of file uInput.cpp.
Definition at line 1068 of file uInput.cpp.
01068 : 01069 uMenuItemInput(uMenu *M,uAction *a,int p) 01070 :uMenuItem(M,a->helpText),act(a),ePlayer(p),active(0){ }
virtual uMenuItemInput::~uMenuItemInput | ( | ) | [inline, virtual] |
virtual void uMenuItemInput::Render | ( | REAL | x, | |
REAL | y, | |||
REAL | alpha = 1 , |
|||
bool | selected = 0 | |||
) | [inline, virtual] |
Reimplemented from uMenuItem.
Definition at line 1074 of file uInput.cpp.
References uBind::act, uBind::CheckPlayer(), DisplayText(), REAL, and su_inputs.
01076 { 01077 DisplayText(REAL(x-.02),y,act->description,selected,alpha,1); 01078 01079 if (active) 01080 { 01081 tString s; 01082 s << tOutput("$input_press_any_key"); 01083 DisplayText(REAL(x+.02),y,s,selected,alpha,-1); 01084 } 01085 else 01086 { 01087 tString s; 01088 01089 bool first=1; 01090 01091 for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i ) 01092 { 01093 uBind * bind = (*i)->GetBind(); 01094 if ( bind && (*i)->Name().size() > 0 && 01095 bind->act==act && 01096 bind->CheckPlayer(ePlayer) ) 01097 { 01098 if (!first) 01099 s << ", "; 01100 else 01101 first=0; 01102 01103 s << (*i)->Name(); 01104 } 01105 } 01106 if (!first) 01107 { 01108 DisplayText(REAL(x+.02),y,s,selected,alpha,-1); 01109 } 01110 else 01111 { 01112 DisplayText(REAL(x+.02),y,tOutput("$input_items_unbound"),selected,alpha,-1); 01113 } 01114 }
virtual void uMenuItemInput::Enter | ( | ) | [inline, virtual] |
virtual bool uMenuItemInput::Event | ( | SDL_Event & | e | ) | [inline, virtual] |
Reimplemented from uMenuItem.
Definition at line 1126 of file uInput.cpp.
References uBind::act, c, uBind::CheckPlayer(), uInput::GetBind(), uTransformEventInfo::input, uBindPlayer::NewBind(), NULL, uInput::SetBind(), su_inputs, su_TransformEvent(), and uTransformEventInfo::value.
01127 { 01128 if ( e.type == SDL_KEYDOWN ) 01129 { 01130 SDL_keysym &c = e.key.keysym; 01131 if (!active) 01132 { 01133 if (c.sym==SDLK_DELETE || c.sym==SDLK_BACKSPACE) 01134 { 01135 // clear all bindings 01136 for ( uInputs::const_iterator i = su_inputs.begin(); i != su_inputs.end(); ++i ) 01137 { 01138 uBind * bind = (*i)->GetBind(); 01139 if ( bind && 01140 bind->act==act && 01141 bind->CheckPlayer(ePlayer) ) 01142 { 01143 (*i)->SetBind( NULL ); 01144 } 01145 } 01146 return true; 01147 } 01148 return false; 01149 } 01150 01151 // ignore escape 01152 if ( c.sym == SDLK_ESCAPE ) 01153 { 01154 return false; 01155 } 01156 } 01157 01158 // transform events 01159 std::vector< uTransformEventInfo > events; 01160 su_TransformEvent( e, events ); 01161 01162 for ( std::vector< uTransformEventInfo >::const_iterator i = events.begin(); i != events.end(); ++i ) 01163 { 01164 uTransformEventInfo const & info = *i; 01165 if ( info.input && info.value > 0.5 && active ) 01166 { 01167 uBind * bind = info.input->GetBind(); 01168 if ( bind && 01169 bind->act==act && 01170 bind->CheckPlayer(ePlayer)) 01171 { 01172 info.input->SetBind( NULL ); 01173 } 01174 else 01175 { 01176 info.input->SetBind( uBindPlayer::NewBind(act,ePlayer) ); 01177 } 01178 01179 active = false; 01180 return true; 01181 } 01182 } 01183 01184 return false;
virtual tString uMenuItemInput::Help | ( | ) | [inline, virtual] |
uAction* uMenuItemInput::act [private] |
Definition at line 1064 of file uInput.cpp.
int uMenuItemInput::ePlayer [private] |
Definition at line 1065 of file uInput.cpp.
bool uMenuItemInput::active [private] |
Definition at line 1066 of file uInput.cpp.