virtual void SetUp() { LuaTest::SetUp(); cpathAppend("../ironbee/util/.libs/?.so"); pathAppend("../?.lua"); pathAppend(TOP_SRCDIR_STR "/lua/?.lua"); doString("ibcutil = require('ibcutil')"); // Clear stack. lua_settop(L, 0); }
void Application::saveXmlConfigFiles(void) { TRACE("Saving configuration file..."); PropertyBag BaseBag, FogBag, PerfBag, window; // Save the mouse sensitivity value BaseBag.add("mouseSensitivity", mouseSensitivity); BaseBag.add("unlockedWorld", unlockedWorld); BaseBag.add("menuMusic", menuMusic); BaseBag.add("soundEnabled", soundEnabled); // Save settings PerfBag.add("useParticleEffects", useParticleEffects); PerfBag.add("useBlurEffects", useBlurEffects); PerfBag.add("textureFilter", textureFilter); PerfBag.add("aniostropy", aniostropy); BaseBag.add("performance", PerfBag); // Save the window settings too window.add("width", (int)g_Window.GetWidth()); window.add("height", (int)g_Window.GetHeight()); window.add("depth", (int)g_Window.GetColorDepth()); window.add("fullscreen", (bool)g_Window.GetFullscreen()); BaseBag.add("window", window); // We'll save settings to the home directory BaseBag.saveToFile(pathAppend(getAppDataDirectory(), defaultSetupFileName)); TRACE("...configuration file saved"); }
void Application::loadXmlConfigFiles(void) { PropertyBag BaseBag, FogBag, PerfBag; string setupFileName = pathAppend(getAppDataDirectory(), defaultSetupFileName); if(File::isFileOnDisk(setupFileName)) { BaseBag.loadFromFile(setupFileName); } else { BaseBag.loadFromFile(defaultSetupFileName); } BaseBag.get("mouseSensitivity", mouseSensitivity); BaseBag.get("unlockedWorld", unlockedWorld); BaseBag.get("menuMusic", menuMusic); BaseBag.get("soundEnabled", soundEnabled); // Load settings BaseBag.get("performance", PerfBag); PerfBag.get("useParticleEffects", useParticleEffects); PerfBag.get("useBlurEffects", useBlurEffects); PerfBag.get("textureFilter", textureFilter); PerfBag.get("aniostropy", aniostropy); if(!supportsAniostropy && textureFilter==2) textureFilter = 1; TRACE("Config files parsed."); }
void BidPage::GetBids() { // get current blockheight and calc next superblock // get current time and calc period long int startdate = 1450396800; // 18 December 2015 00:00 long int current = GetTime(); long int diff = current - startdate; int until = 86400 - (diff % 86400); ui->labelNumber->setText(GUIUtil::formatDurationStr(until)); // get default datadir, tack on bidtracker QString dataDir = getDefaultDataDirectory(); QString bidDir = "bidtracker"; QString datPath = pathAppend(dataDir, bidDir); // get bids from /bidtracker/final.dat QString bidspath = QDir(datPath).filePath("prefinal.dat"); double btctot = 0; // for each line in file, get the float after the comma QFile bidsFile(bidspath); if (bidsFile.open(QIODevice::ReadOnly)) { QTextStream btcin(&bidsFile); while (!btcin.atEnd()) { QString line = btcin.readLine(); if (line.isEmpty()){ continue; } else if (line.startsWith("1")) // BTC { QString btcamount = line.remove(0, 35); btctot = btctot + btcamount.toDouble(); } else // we should never get here { QMessageBox::information(0, QString("Oops!"), QString("There is a problem with the file, please try again later!"), QMessageBox::Ok); } } bidsFile.close(); } // btctot, ltctot and dashtot are in satoshis, so divide by 10000000 to get right units // to do - add radiobuttons or dropdown to select sats or not? double btctotU = btctot / 100000000; QString btctotal = QString::number(btctotU, 'f', 8); ui->labelBTC_2->setText(btctotal); // add 'em up and display 'em double alltot = btctotU; QString alltotal = QString::number(alltot, 'f', 8); ui->labelTotal_2->setText(alltotal); // calc price per BCR based on total bids and display it double bcrprice = alltot / 31500; QString bcrPrice = QString::number(bcrprice, 'f', 8); ui->labelEstprice_2->setText(bcrPrice); ui->lineEditBid->setEnabled(true); }
void out_init(jmp_buf jmpBuf, struct Output* output, char* configDir) { struct ConfigParser parser; struct ConfigParserEntry entry[] = { StringConfigEntry("display:separator", separator, NULL), IntConfigEntry("display:monitors", monitors, 1), EndConfigEntry(), }; cp_init(jmpBuf, &parser, entry); char* path = pathAppend(configDir, "bard.conf"); cp_load(jmpBuf, &parser, path, output); free(path); cp_kill(&parser); for(int i = ALIGN_FIRST; i <= ALIGN_LAST; i++) { vector_init(jmpBuf, &output->out[i], sizeof(struct Unit*), 10); } }
void Application::startOpenGL() { PropertyBag xml, window; bool fullscreen = false; // whether to set fullscreen int width = 800; // dimensions of window int height = 600; // dimensions of window int depth = 32; // bits per pixel const string setupFileName = pathAppend(getAppDataDirectory(), defaultSetupFileName); if(File::isFileOnDisk(setupFileName)) { xml.loadFromFile(setupFileName); } else { xml.loadFromFile(defaultSetupFileName); } if(xml.exists("window")) { xml.get("window", window); window.get("width", width); window.get("height", height); window.get("depth", depth); window.get("fullscreen", fullscreen); } // Create an OpenGL context new SDLWindow(*this); g_Window.Create("Game Creation Society", width, height, SDLWindow::R8G8B8A8, 24, fullscreen); new OpenGL(width, height); TRACE("Created OpenGL context and window"); if(fullscreen) { SDL_ShowCursor(0); } }
void _3dsLoader::readMaterialMapFile(Chunk ¤tChunk, Material &material) const { ASSERT(currentChunk.getID()==MATMAPFILE, "Expected chunk ID MATMAPFILE"); const size_t size = currentChunk.getSize() - currentChunk.tell(); char *relativeFileName = new char[size]; currentChunk.read(relativeFileName, size); const string chunkFile = currentChunk.getFilename(); const string path = File::getPath(chunkFile); const string absoluteFileName = pathAppend(path, relativeFileName); TRACE("3DS current file: " + chunkFile); TRACE("3DS current path: " + path); TRACE(string("3DS material: ") + relativeFileName); TRACE("Reading 3DS material from: " + absoluteFileName); material.loadTexture(absoluteFileName, 0); delete[] relativeFileName; }
void EditorToolBar::onLeftMouseDown() { ASSERT(world!=0, "world was null! Call setWorld first!"); if(g_GUI.mouseOverSomeWidget) return; // Get a position on the ground beneath the cursor float e = selected ? selected->getPos().y : 0.0f; const vec3 groundPos = getGroundPickPos(e); // Grab the pool of objects we are working from ActorSet &objects = world->getObjects(); // Get the id of the object under the mouse cursor OBJECT_ID id = objects.getClosest<Actor>(groundPos, 2.0f); // Process the action depending on the current tool switch(toolBarTools->getTool()) { case ToolBarForEditorTools::EDITOR_SELECT_TOOL: if(objects.isMember(id)) { Actor * p = &objects.get(id); showActorPane(p); } else { hideActorPane(); } break; case ToolBarForEditorTools::EDITOR_MOVE_TOOL: { if(selected) { // Hold the right mouse button to slide objects along the y-axis if(g_Input.MouseRight) { vec3 delta = groundPos - selected->getPos(); delta.y=0; float dist = delta.getMagnitude()*0.3f; // Place the object on this spot selected->Place(vec3(selected->getPos().x, dist, selected->getPos().z)); } else { selected->Place(groundPos); } } } break; case ToolBarForEditorTools::EDITOR_ROTATE_TOOL: { if(selected) { const vec3 delta = vec3(selected->getPos().x-groundPos.x, 0, selected->getPos().z-groundPos.z); const vec3 zAxis = delta.getNormal(); const vec3 yAxis = vec3(0,1,0); const vec3 xAxis = yAxis.cross(zAxis).getNormal(); mat4 orientation = selected->getOrientation(); orientation.setAxisZ(zAxis); orientation.setAxisY(yAxis); orientation.setAxisX(xAxis); orientation.setPos(vec3(0,0,0)); selected->setOrientation(orientation); } } break; case ToolBarForEditorTools::EDITOR_ROTATE_X_TOOL: { if(selected) { vec3 delta = groundPos - selected->getPos(); float angle = atan2f(delta.x, delta.y) * 0.1f; mat4 rot; rot.rotateX(angle); mat4 orientation = selected->getOrientation(); orientation *= rot; selected->setOrientation(orientation); } } break; case ToolBarForEditorTools::EDITOR_ROTATE_Z_TOOL: { if(selected) { vec3 delta = groundPos - selected->getPos(); float angle = atan2f(delta.x, delta.y) * 0.1f; mat4 rot; rot.rotateZ(angle); mat4 orientation = selected->getOrientation(); orientation *= rot; selected->setOrientation(orientation); } } break; case ToolBarForEditorTools::EDITOR_CREATE_TOOL: if(!leftClickDebounce) { leftClickDebounce=true; // Create objects from a palette of available types string nextObject = getNextObject(); // Gets the objects for the object palette string editorDataFile = pathAppend("data/objects/", nextObject); PropertyBag ThisObjBag; ThisObjBag.loadFromFile(editorDataFile); string rtti; ThisObjBag.get("type", rtti); // Create the object inside the game world OBJECT_ID id = objects.create(rtti, world); if(id != INVALID_ID) { Actor &object = objects.get(id); object.load(ThisObjBag); object.editorDataFile = editorDataFile; // Do not affect object y with the move command vec3 groundPos = getGroundPickPos(0.0f); // Place the object on this spot object.Place(groundPos); // Select the new object selected = &object; } } break; case ToolBarForEditorTools::EDITOR_DESTROY_TOOL: if(objects.isMember(id)) { objects.removeObjectNow(id); hideActorPane(); } break; case ToolBarForEditorTools::EDITOR_TILE_PENCIL_TOOL: { // get a reference to the map Map &map = world->getMap(); // Get the position on the ground plane that was clicked vec3 groundPos = getGroundPickPos(0.0f); if(map.onATile(groundPos.x, groundPos.z)) { // get the tile that was picked Tile &tile = map.getTile(groundPos.x, groundPos.z); #if 1 tile.create(map.tileX(groundPos.x), map.tileZ(groundPos.z), tileEditor_type, tileEditor_properties, tileEditor_height, tileEditor_floorTextureFile, tileEditor_wallTextureFile, map); #else tile.setMaterials(tileEditor_wallTextureFile, tileEditor_floorTextureFile, map); #endif // Rebuild the map display list map.reaquire(); g_SoundSystem.play("data/sound/click.wav"); } } break; case ToolBarForEditorTools::EDITOR_TILE_BLOCK_TOOL: { // Drag entered if(!drag) { drag = true; g_SoundSystem.play("data/sound/click.wav"); mouseDownPos = getGroundPickPos(0.0f); } } break; }; }
string EditorToolBar::chooseTileFloorTexture(void) { ASSERT(texturePalette_Floor!=0, "EditorToolBar::chooseTileFloorTexture -> texturePalette_Floor was null"); return pathAppend("data/tiles/floor", texturePalette_Floor->getFilename()); }
string EditorToolBar::chooseTileWallTexture(void) { ASSERT(texturePalette_Wall!=0, "EditorToolBar::chooseTileWallTexture -> texturePalette_Wall was null"); return pathAppend("data/tiles/wall", texturePalette_Wall->getFilename()); }
void TestPage::GetBids() { // get current blockheight and calc next superblock int base = 200700; int current = TestPage::getNumBlocks(); int diff = current - base; int until = 900 - (diff % 900); QString blocks = QString::number(until); ui->labelNumber->setText(blocks); // get default datadir, tack on bidtracker QString dataDir = getDefaultDataDirectory(); QString bidDir = "bidtracker"; QString datPath = pathAppend(dataDir, bidDir); // get bids from /bidtracker/final.dat QString bidspath = QDir(datPath).filePath("final.dat"); double btctot = 0; double ltctot = 0; double dashtot = 0; // for each line in file, get the float after the comma QFile bidsFile(bidspath); if (bidsFile.open(QIODevice::ReadOnly)) { QTextStream btcin(&bidsFile); while (!btcin.atEnd()) { QString line = btcin.readLine(); if (line.startsWith("1")) // BTC { QString btcamount = line.remove(0, 35); btctot = btctot + btcamount.toDouble(); } else if (line.startsWith("L")) // LTC { QString ltcamount = line.remove(0, 35); ltctot = ltctot + ltcamount.toDouble(); } else if (line.startsWith("X")) // DASH { QString dashamount = line.remove(0, 35); dashtot = dashtot + dashamount.toDouble(); } else // we should never get here { QMessageBox::information(0, QString("Oops!"), QString("There is a problem with the file, please try again later!"), QMessageBox::Ok); } } bidsFile.close(); } // btctot, ltctot and dashtot are in satoshis, so divide by 10000000 to get right units // to do - add radiobuttons or dropdown to select sats or not? double btctotU = btctot / 100000000; double ltctotU = ltctot / 100000000; double dashtotU = dashtot / 100000000; QString btctotal = QString::number(btctotU, 'f', 8); QString ltctotal = QString::number(ltctotU, 'f', 8); QString dashtotal = QString::number(dashtotU, 'f', 8); ui->labelBTC_2->setText(btctotal); ui->labelLTC_2->setText(ltctotal); ui->labelDASH_2->setText(dashtotal); // add 'em up and display 'em double alltot = btctotU + ltctotU + dashtotU; QString alltotal = QString::number(alltot, 'f', 8); ui->labelTotal_2->setText(alltotal); // calc price per BCR based on total bids and display it double bcrprice = alltot / 30000; QString bcrPrice = QString::number(bcrprice, 'f', 8); ui->labelEstprice_2->setText(bcrPrice); ui->lineEditBid->setEnabled(true); }