[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[5068] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[7374] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SHELL |
---|
[1853] | 17 | |
---|
[5068] | 18 | #include "shell.h" |
---|
[5129] | 19 | #include "shell_command.h" |
---|
[5175] | 20 | #include "shell_buffer.h" |
---|
[5179] | 21 | #include "shell_input.h" |
---|
[1853] | 22 | |
---|
[7737] | 23 | #include "multi_line_text.h" |
---|
[5175] | 24 | |
---|
[5093] | 25 | #include "graphics_engine.h" |
---|
[5372] | 26 | #include "material.h" |
---|
[5093] | 27 | #include "event_handler.h" |
---|
[5113] | 28 | |
---|
[7374] | 29 | namespace OrxShell |
---|
| 30 | { |
---|
[1853] | 31 | |
---|
[7422] | 32 | SHELL_COMMAND(clear, Shell, clear) |
---|
| 33 | ->describe("Clears the shell from unwanted lines (empties all buffers)") |
---|
| 34 | ->setAlias("clear"); |
---|
| 35 | SHELL_COMMAND(deactivate, Shell, deactivate) |
---|
| 36 | ->describe("Deactivates the Shell. (moves it into background)") |
---|
| 37 | ->setAlias("hide"); |
---|
| 38 | SHELL_COMMAND(textsize, Shell, setTextSize) |
---|
| 39 | ->describe("Sets the size of the Text size, linespacing") |
---|
| 40 | ->defaultValues(15, 0); |
---|
| 41 | SHELL_COMMAND(textcolor, Shell, setTextColor) |
---|
| 42 | ->describe("Sets the Color of the Shells Text (red, green, blue, alpha)") |
---|
| 43 | ->defaultValues(SHELL_DEFAULT_TEXT_COLOR); |
---|
| 44 | SHELL_COMMAND(backgroundcolor, Shell, setBackgroundColor) |
---|
| 45 | ->describe("Sets the Color of the Shells Background (red, green, blue, alpha)") |
---|
| 46 | ->defaultValues(SHELL_DEFAULT_BACKGROUND_COLOR); |
---|
| 47 | SHELL_COMMAND(backgroundimage, Shell, setBackgroundImage) |
---|
| 48 | ->describe("sets the background image to load for the Shell") |
---|
| 49 | ->completionPlugin(0, OrxShell::CompletorFileSystem()); |
---|
| 50 | SHELL_COMMAND(font, Shell, setFont) |
---|
| 51 | ->describe("Sets the font of the Shell") |
---|
| 52 | ->defaultValues(SHELL_DEFAULT_FONT) |
---|
| 53 | ->completionPlugin(0, OrxShell::CompletorFileSystem(".ttf", "fonts/")); |
---|
[1856] | 54 | |
---|
[7422] | 55 | /** |
---|
| 56 | * standard constructor |
---|
| 57 | */ |
---|
| 58 | Shell::Shell () |
---|
| 59 | { |
---|
| 60 | this->setClassID(CL_SHELL, "Shell"); |
---|
| 61 | this->setName("Shell"); |
---|
[5072] | 62 | |
---|
[7422] | 63 | // EVENT-Handler subscription of '`' to all States. |
---|
| 64 | EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_BACKQUOTE); |
---|
| 65 | EventHandler::getInstance()->subscribe(this, ES_ALL, SDLK_F12); |
---|
| 66 | EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEUP); |
---|
| 67 | EventHandler::getInstance()->subscribe(this, ES_SHELL, SDLK_PAGEDOWN); |
---|
[5206] | 68 | |
---|
[7422] | 69 | // BUFFER |
---|
| 70 | this->bufferOffset = 0; |
---|
| 71 | this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin(); |
---|
[5372] | 72 | |
---|
[7422] | 73 | // INPUT LINE |
---|
| 74 | this->setLayer(E2D_LAYER_ABOVE_ALL); |
---|
| 75 | this->shellInput.setLayer(E2D_LAYER_ABOVE_ALL); |
---|
[5372] | 76 | |
---|
[7422] | 77 | this->backgroundMaterial = new Material; |
---|
[7341] | 78 | |
---|
[7422] | 79 | // Element2D and generals |
---|
| 80 | this->setAbsCoor2D(3, -400); |
---|
[7426] | 81 | this->textSize = 15; |
---|
[7422] | 82 | this->lineSpacing = 0; |
---|
| 83 | this->bActive = true; |
---|
| 84 | this->fontFile = SHELL_DEFAULT_FONT; |
---|
[5072] | 85 | |
---|
[7422] | 86 | this->setBufferDisplaySize(10); |
---|
[5080] | 87 | |
---|
[7422] | 88 | this->setTextColor(SHELL_DEFAULT_TEXT_COLOR); |
---|
| 89 | this->setBackgroundColor(SHELL_DEFAULT_BACKGROUND_COLOR); |
---|
[5335] | 90 | |
---|
[7341] | 91 | |
---|
[7422] | 92 | this->deactivate(); |
---|
| 93 | // register the shell at the ShellBuffer |
---|
| 94 | ShellBuffer::getInstance()->registerShell(this); |
---|
| 95 | } |
---|
[4320] | 96 | |
---|
[7422] | 97 | /** |
---|
| 98 | * @brief standard deconstructor |
---|
| 99 | */ |
---|
| 100 | Shell::~Shell () |
---|
| 101 | { |
---|
| 102 | ShellBuffer::getInstance()->unregisterShell(this); |
---|
[5335] | 103 | |
---|
[7422] | 104 | // delete the displayable Buffers |
---|
| 105 | while (!this->bufferText.empty()) |
---|
| 106 | { |
---|
| 107 | delete this->bufferText.front(); |
---|
| 108 | this->bufferText.pop_front(); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | // delete the inputLine |
---|
| 112 | delete this->backgroundMaterial; |
---|
[7341] | 113 | } |
---|
| 114 | |
---|
[7422] | 115 | /** |
---|
| 116 | * @brief activates the shell |
---|
| 117 | * |
---|
| 118 | * This also feeds the Last few lines from the main buffers into the displayBuffer |
---|
| 119 | */ |
---|
| 120 | void Shell::activate() |
---|
| 121 | { |
---|
| 122 | if (this->bActive == true) |
---|
| 123 | PRINTF(3)("The shell is already active\n"); |
---|
| 124 | this->bActive = true; |
---|
[5068] | 125 | |
---|
[7422] | 126 | EventHandler::getInstance()->pushState(ES_SHELL); |
---|
| 127 | EventHandler::getInstance()->withUNICODE(true); |
---|
[5113] | 128 | |
---|
[7422] | 129 | this->setRelCoorSoft2D(0, 0, 5); |
---|
[5786] | 130 | |
---|
[7422] | 131 | std::list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end(); |
---|
| 132 | bool top = false; |
---|
[7737] | 133 | for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) |
---|
[5787] | 134 | { |
---|
[7422] | 135 | (*text)->setVisibility(true); |
---|
| 136 | if (!top) |
---|
| 137 | { |
---|
| 138 | (*text)->setText((*textLine)); |
---|
| 139 | if (textLine != ShellBuffer::getInstance()->getBuffer().begin()) |
---|
| 140 | top = true; |
---|
| 141 | textLine--; |
---|
| 142 | } |
---|
[5787] | 143 | } |
---|
[5247] | 144 | } |
---|
[5113] | 145 | |
---|
[7422] | 146 | /** |
---|
| 147 | * @brief deactiveates the Shell. |
---|
| 148 | */ |
---|
| 149 | void Shell::deactivate() |
---|
| 150 | { |
---|
| 151 | if (this->bActive == false) |
---|
| 152 | PRINTF(3)("The shell is already inactive\n"); |
---|
| 153 | this->bActive = false; |
---|
[5113] | 154 | |
---|
[7422] | 155 | EventHandler::getInstance()->withUNICODE(false); |
---|
| 156 | EventHandler::getInstance()->popState(); |
---|
[5388] | 157 | |
---|
[7422] | 158 | this->setRelCoorSoft2D(0, -(int)this->shellHeight, 5); |
---|
[5118] | 159 | |
---|
[7737] | 160 | for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) |
---|
[7422] | 161 | (*text)->setVisibility(false); |
---|
| 162 | this->bufferOffset = 0; |
---|
| 163 | } |
---|
[5113] | 164 | |
---|
[7422] | 165 | /** |
---|
| 166 | * @brief sets the File to load the fonts from |
---|
| 167 | * @param fontFile the file to load the font from |
---|
| 168 | * |
---|
| 169 | * it is quite important, that the font pointed too really exists! |
---|
| 170 | * (be aware that within orxonox fontFile is relative to the Data-Dir) |
---|
| 171 | */ |
---|
| 172 | void Shell::setFont(const std::string& fontFile) |
---|
| 173 | { |
---|
| 174 | // if (!ResourceManager::isInDataDir(fontFile)) |
---|
| 175 | // return false; |
---|
[5335] | 176 | |
---|
[7422] | 177 | this->fontFile = fontFile; |
---|
[5251] | 178 | |
---|
[7422] | 179 | this->resetValues(); |
---|
| 180 | } |
---|
[5251] | 181 | |
---|
[7422] | 182 | /** |
---|
| 183 | * @brief sets the size of the text and spacing |
---|
| 184 | * @param textSize the size of the Text in Pixels |
---|
| 185 | * @param lineSpacing the size of the Spacing between two lines in pixels |
---|
| 186 | * |
---|
| 187 | * this also rebuilds the entire Text, inputLine and displayBuffer, |
---|
| 188 | * to be accurate again. |
---|
| 189 | */ |
---|
| 190 | void Shell::setTextSize(unsigned int textSize, unsigned int lineSpacing) |
---|
| 191 | { |
---|
| 192 | this->textSize = textSize; |
---|
| 193 | this->lineSpacing = lineSpacing; |
---|
[7341] | 194 | |
---|
[7422] | 195 | this->resetValues(); |
---|
| 196 | } |
---|
[5113] | 197 | |
---|
[7422] | 198 | /** |
---|
| 199 | * @brief sets the color of the Font. |
---|
| 200 | * @param r: red |
---|
| 201 | * @param g: green |
---|
| 202 | * @param b: blue |
---|
| 203 | * @param a: alpha-value. |
---|
| 204 | */ |
---|
| 205 | void Shell::setTextColor(float r, float g, float b, float a) |
---|
| 206 | { |
---|
| 207 | this->textColor[0] = r; |
---|
| 208 | this->textColor[1] = g; |
---|
| 209 | this->textColor[2] = b; |
---|
| 210 | this->textColor[3] = a; |
---|
[5372] | 211 | |
---|
[7422] | 212 | this->resetValues(); |
---|
| 213 | } |
---|
[5372] | 214 | |
---|
| 215 | |
---|
[7422] | 216 | /** |
---|
| 217 | * @brief sets the color of the Backgrond. |
---|
| 218 | * @param r: red |
---|
| 219 | * @param g: green |
---|
| 220 | * @param b: blue |
---|
| 221 | * @param a: alpha-value. |
---|
| 222 | */ |
---|
| 223 | void Shell::setBackgroundColor(float r, float g, float b, float a) |
---|
| 224 | { |
---|
| 225 | this->backgroundMaterial->setDiffuse(r, g, b); |
---|
| 226 | this->backgroundMaterial->setTransparency(a); |
---|
| 227 | } |
---|
[5372] | 228 | |
---|
[7422] | 229 | /** |
---|
| 230 | * @brief sets a nice background image to the Shell's background |
---|
| 231 | * @param fileName the filename of the Image to load |
---|
| 232 | */ |
---|
| 233 | void Shell::setBackgroundImage(const std::string& fileName) |
---|
| 234 | { |
---|
| 235 | this->backgroundMaterial->setDiffuseMap(fileName); |
---|
| 236 | } |
---|
[5374] | 237 | |
---|
| 238 | |
---|
[7422] | 239 | /** |
---|
| 240 | * @brief resets the Values of all visible shell's commandos to the Shell's stored values |
---|
| 241 | * |
---|
| 242 | * this functions synchronizes the stored Data with the visible one. |
---|
| 243 | */ |
---|
| 244 | void Shell::resetValues() |
---|
| 245 | { |
---|
[7426] | 246 | this->resetText(&this->shellInput, 0); |
---|
| 247 | this->shellInput.setRelCoor2D(15, (this->textSize + this->lineSpacing)*(this->bufferDisplaySize)); |
---|
[5372] | 248 | |
---|
[7422] | 249 | unsigned int i = 0; |
---|
[7426] | 250 | /* Here we create a Copy of the Buffer, so that we do not f**k up the List when some |
---|
| 251 | * output is routed from Some other Thread or by Changing any Values. |
---|
| 252 | */ |
---|
[7737] | 253 | std::list<MultiLineText*> bufferTextCopy = this->bufferText; |
---|
| 254 | for (std::list<MultiLineText*>::iterator text = bufferTextCopy.begin(); text != bufferTextCopy.end(); ++text, ++i) |
---|
[7422] | 255 | { |
---|
[7426] | 256 | this->resetText(*text, i); |
---|
[7422] | 257 | (*text)->setRelCoor2D( calculateLinePosition(i) ); |
---|
| 258 | } |
---|
| 259 | this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); |
---|
[5369] | 260 | } |
---|
[5113] | 261 | |
---|
[7426] | 262 | void Shell::resetText(Text* text, unsigned int position) |
---|
| 263 | { |
---|
| 264 | text->setFont(this->fontFile, this->textSize); |
---|
| 265 | text->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); |
---|
| 266 | text->setBlending(this->textColor[3]); |
---|
| 267 | text->setLayer(this->getLayer()); |
---|
| 268 | if (text->getParent2D() != this) |
---|
| 269 | text->setParent2D(this); |
---|
| 270 | } |
---|
[5113] | 271 | |
---|
[7426] | 272 | |
---|
[7422] | 273 | /** |
---|
| 274 | * @brief sets The count of Lines to display in the buffer. |
---|
| 275 | * @param bufferDisplaySize the count of lines to display in the Shell-Buffer. |
---|
| 276 | */ |
---|
| 277 | void Shell::setBufferDisplaySize(unsigned int bufferDisplaySize) |
---|
[5072] | 278 | { |
---|
[7422] | 279 | unsigned int oldSize = this->bufferText.size(); |
---|
| 280 | if (oldSize > bufferDisplaySize) |
---|
[7341] | 281 | { |
---|
[7422] | 282 | for (unsigned int i = bufferDisplaySize; i <= oldSize; i++) |
---|
| 283 | { |
---|
| 284 | delete this->bufferText.back(); |
---|
| 285 | this->bufferText.pop_back(); |
---|
| 286 | } |
---|
[7341] | 287 | } |
---|
[7422] | 288 | else if (oldSize < bufferDisplaySize) |
---|
| 289 | { |
---|
| 290 | for (unsigned int i = oldSize; i <= bufferDisplaySize; i++) |
---|
| 291 | { |
---|
[7737] | 292 | this->bufferText.push_back(new MultiLineText); |
---|
| 293 | this->bufferText.back()->setLineWidth(this->getSizeX2D() * GraphicsEngine::getInstance()->getResolutionX()); |
---|
| 294 | this->bufferText.back()->setLineSpacing(0); |
---|
[7422] | 295 | } |
---|
| 296 | } |
---|
| 297 | this->bufferDisplaySize = bufferDisplaySize; |
---|
| 298 | this->resetValues(); |
---|
[5072] | 299 | } |
---|
[7422] | 300 | |
---|
| 301 | /** |
---|
| 302 | * @brief deletes all the Buffers |
---|
| 303 | */ |
---|
| 304 | void Shell::flush() |
---|
[5072] | 305 | { |
---|
[7737] | 306 | for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text) |
---|
[5787] | 307 | { |
---|
[7422] | 308 | (*text)->setText(""); // remove all chars from the BufferTexts. |
---|
[5787] | 309 | } |
---|
[7422] | 310 | ShellBuffer::getInstance()->flush(); |
---|
| 311 | // BUFFER FLUSHING |
---|
[5072] | 312 | } |
---|
[5068] | 313 | |
---|
[7422] | 314 | /** |
---|
| 315 | * @brief prints out some text to the input-buffers |
---|
| 316 | * @param text the text to output. |
---|
| 317 | */ |
---|
| 318 | void Shell::printToDisplayBuffer(const std::string& text) |
---|
[7341] | 319 | { |
---|
[7737] | 320 | // Remove Last Entry and prepend it to the front. |
---|
[7422] | 321 | this->bufferText.push_front(this->bufferText.back()); |
---|
| 322 | this->bufferText.pop_back(); |
---|
[5068] | 323 | |
---|
[7737] | 324 | // Set the new Text. |
---|
| 325 | this->bufferText.front()->setText(text); |
---|
[7341] | 326 | |
---|
[7737] | 327 | // The LineCount will be started here. |
---|
| 328 | int linePos = -1; |
---|
| 329 | |
---|
| 330 | // The First Line gets a special Animation |
---|
| 331 | this->bufferText.front()->setRelCoor2D(this->calculateLinePosition(linePos)- Vector2D(-1000,0)); |
---|
| 332 | |
---|
| 333 | // Move all lines one Entry up. |
---|
| 334 | for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) |
---|
[7422] | 335 | { |
---|
[7737] | 336 | linePos += (*textIt)->getLineCount(); |
---|
| 337 | (*textIt)->setRelCoorSoft2D(this->calculateLinePosition(linePos), 8); |
---|
[7422] | 338 | } |
---|
[7341] | 339 | |
---|
[5113] | 340 | |
---|
[7422] | 341 | /* FANCY EFFECTS :) |
---|
| 342 | 1: |
---|
| 343 | lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0)); |
---|
| 344 | lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10); |
---|
| 345 | 2: |
---|
| 346 | lastText->setRelDir2D(-90); |
---|
| 347 | lastText->setRelDirSoft2D(0, 20); |
---|
| 348 | */ |
---|
[5375] | 349 | |
---|
[7341] | 350 | } |
---|
[5783] | 351 | |
---|
[7422] | 352 | /** |
---|
| 353 | * moves the Display buffer (up + or down - ) |
---|
| 354 | * @param lineCount the count by which to shift the InputBuffer. |
---|
| 355 | * |
---|
| 356 | * @todo make this work |
---|
| 357 | */ |
---|
| 358 | void Shell::moveDisplayBuffer(int lineCount) |
---|
[5783] | 359 | { |
---|
[7422] | 360 | if (this->bufferOffset == 0) |
---|
[5783] | 361 | { |
---|
[7422] | 362 | this->bufferIterator = ShellBuffer::getInstance()->getBuffer().end(); |
---|
| 363 | // for (unsigned int i = 0; i < this->bufferDisplaySize; i++) |
---|
| 364 | // this->bufferIterator->prevStep(); |
---|
[5783] | 365 | } |
---|
[7422] | 366 | |
---|
| 367 | // boundraries |
---|
| 368 | if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer().size()) |
---|
| 369 | lineCount = (int)ShellBuffer::getInstance()->getBuffer().size()- this->bufferOffset; |
---|
| 370 | else if (this->bufferOffset + lineCount < 0) |
---|
| 371 | lineCount = -bufferOffset; |
---|
| 372 | this->bufferOffset += lineCount; |
---|
| 373 | |
---|
| 374 | // moving the iterator to the right position |
---|
| 375 | int move = 0; |
---|
| 376 | while (move != lineCount) |
---|
[5783] | 377 | { |
---|
[7422] | 378 | if (move < lineCount) |
---|
| 379 | { |
---|
| 380 | ++move; |
---|
| 381 | this->bufferIterator--; |
---|
| 382 | } |
---|
| 383 | else |
---|
| 384 | { |
---|
| 385 | --move; |
---|
| 386 | this->bufferIterator++; |
---|
| 387 | } |
---|
[5783] | 388 | } |
---|
[7422] | 389 | // redisplay the buffers |
---|
| 390 | std::list<std::string>::const_iterator it = this->bufferIterator; |
---|
| 391 | if (it == ShellBuffer::getInstance()->getBuffer().end()) |
---|
[7342] | 392 | { |
---|
| 393 | /// FIXME |
---|
[7737] | 394 | PRINTF(1)("Should not happen\n"); |
---|
[7422] | 395 | it--; |
---|
[7342] | 396 | } |
---|
[7737] | 397 | for (std::list<MultiLineText*>::iterator textIt = this->bufferText.begin(); textIt != this->bufferText.end(); ++textIt) |
---|
[7422] | 398 | { |
---|
| 399 | (*textIt)->setText((*it)); |
---|
| 400 | if (it == ShellBuffer::getInstance()->getBuffer().begin()) |
---|
| 401 | { |
---|
| 402 | /// FIXME |
---|
[7737] | 403 | PRINTF(1)("Should not happen\n"); |
---|
[7422] | 404 | break; |
---|
| 405 | } |
---|
| 406 | it--; |
---|
| 407 | } |
---|
[5783] | 408 | } |
---|
[5246] | 409 | |
---|
[7422] | 410 | /** |
---|
| 411 | * clears the Shell (empties all buffers) |
---|
| 412 | */ |
---|
| 413 | void Shell::clear() |
---|
| 414 | { |
---|
| 415 | this->flush(); |
---|
| 416 | ShellBuffer::addBufferLineStatic("orxonox - shell\n ==================== \n", NULL); |
---|
| 417 | } |
---|
[5130] | 418 | |
---|
[7422] | 419 | /** |
---|
| 420 | * listens for some event |
---|
| 421 | * @param event the Event happened |
---|
| 422 | */ |
---|
| 423 | void Shell::process(const Event &event) |
---|
[5093] | 424 | { |
---|
[7422] | 425 | if (event.bPressed) |
---|
[5093] | 426 | { |
---|
[7422] | 427 | if (event.type == SDLK_BACKQUOTE || event.type == SDLK_F12) |
---|
| 428 | { |
---|
| 429 | if (this->bActive == false) |
---|
| 430 | this->activate(); |
---|
| 431 | else |
---|
| 432 | this->deactivate(); |
---|
| 433 | } |
---|
| 434 | else if (event.type == SDLK_PAGEUP) |
---|
| 435 | { |
---|
| 436 | this->moveDisplayBuffer(+this->bufferDisplaySize-1); |
---|
| 437 | } |
---|
| 438 | else if (event.type == SDLK_PAGEDOWN) |
---|
| 439 | { |
---|
| 440 | this->moveDisplayBuffer(-this->bufferDisplaySize+1); |
---|
| 441 | } |
---|
[5093] | 442 | } |
---|
| 443 | } |
---|
[5069] | 444 | |
---|
[7422] | 445 | /** |
---|
| 446 | * displays the Shell |
---|
| 447 | */ |
---|
| 448 | void Shell::draw() const |
---|
| 449 | { |
---|
| 450 | // transform for alignment. |
---|
| 451 | // setting the Blending effects |
---|
[5099] | 452 | |
---|
[7422] | 453 | this->backgroundMaterial->select(); |
---|
[5099] | 454 | |
---|
[7422] | 455 | glBegin(GL_TRIANGLE_STRIP); |
---|
[5099] | 456 | |
---|
[7422] | 457 | glTexCoord2f(0, 0); |
---|
| 458 | glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y ); |
---|
[5099] | 459 | |
---|
[7422] | 460 | glTexCoord2f(1, 0); |
---|
| 461 | glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y ); |
---|
[5099] | 462 | |
---|
[7422] | 463 | glTexCoord2f(0, 1); |
---|
| 464 | glVertex2f(this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight); |
---|
[5158] | 465 | |
---|
[7422] | 466 | glTexCoord2f(1, 1); |
---|
| 467 | glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight); |
---|
[5099] | 468 | |
---|
[7422] | 469 | glEnd(); |
---|
| 470 | } |
---|
[5068] | 471 | |
---|
[7422] | 472 | /////////////////////// |
---|
| 473 | // HELPER FUNCTIONS // |
---|
| 474 | /////////////////////// |
---|
[5166] | 475 | |
---|
[7422] | 476 | /** |
---|
| 477 | * @brief calculates the position of a Buffer-Display Line |
---|
| 478 | * @param lineNumber the lineNumber from the bottom to calculate the position from |
---|
| 479 | * @returns the Position of the Line. |
---|
| 480 | */ |
---|
| 481 | Vector2D Shell::calculateLinePosition(unsigned int lineNumber) |
---|
| 482 | { |
---|
[7737] | 483 | Vector2D val(5, (int)(this->textSize + this->lineSpacing)*(int)((int)this->bufferDisplaySize - (int)lineNumber - (int)2) + (int)this->textSize); |
---|
| 484 | val.debug(); |
---|
| 485 | return val; |
---|
[7422] | 486 | } |
---|
[5120] | 487 | |
---|
| 488 | |
---|
| 489 | |
---|
[7422] | 490 | /** |
---|
| 491 | * @brief displays some nice output from the Shell |
---|
| 492 | */ |
---|
| 493 | void Shell::debug() const |
---|
| 494 | { |
---|
| 495 | PRINT(3)("Debugging output to console (not this shell)\n"); |
---|
[5119] | 496 | |
---|
[7422] | 497 | // if (this->pressedKey != SDLK_FIRST) |
---|
| 498 | // printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay); |
---|
[5119] | 499 | |
---|
| 500 | |
---|
[7422] | 501 | ShellBuffer::getInstance()->debug(); |
---|
| 502 | } |
---|
[5166] | 503 | |
---|
[7422] | 504 | // void Shell::testI (int i) |
---|
| 505 | // { |
---|
| 506 | // PRINTF(3)("This is the Test for one Int '%d'\n", i); |
---|
| 507 | // } |
---|
| 508 | // |
---|
| 509 | // void Shell::testS (const char* s) |
---|
| 510 | // { |
---|
| 511 | // PRINTF(3)("This is the Test for one String '%s'\n", s); |
---|
| 512 | // } |
---|
| 513 | // |
---|
| 514 | // void Shell::testB (bool b) |
---|
| 515 | // { |
---|
| 516 | // PRINTF(3)("This is the Test for one Bool: "); |
---|
| 517 | // if (b) |
---|
| 518 | // PRINTF(3)("true\n"); |
---|
| 519 | // else |
---|
| 520 | // PRINTF(3)("false\n"); |
---|
| 521 | // } |
---|
| 522 | // |
---|
| 523 | // void Shell::testF (float f) |
---|
| 524 | // { |
---|
| 525 | // PRINTF(3)("This is the Test for one Float '%f'\n", f); |
---|
| 526 | // } |
---|
| 527 | // |
---|
| 528 | // void Shell::testSF (const char* s, float f) |
---|
| 529 | // { |
---|
| 530 | // PRINTF(3)("This is the Test for one String '%s' and one Float '%f'\n",s , f); |
---|
| 531 | // } |
---|
[7374] | 532 | |
---|
| 533 | } |
---|