EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): Window(_("Equipment"), false, nullptr, "equipment.xml"), mEquipment(equipment), mSelected(-1), mForing(foring), mImageSet(nullptr) { mBeing = being; mItemPopup = new ItemPopup; if (setupWindow) setupWindow->registerWindowForReset(this); // Control that shows the Player mPlayerBox = new PlayerBox; mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); if (foring) setWindowName("Being equipment"); else setWindowName("Equipment"); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); setDefaultSize(180, 345, ImageRect::CENTER); mBoxes.reserve(BOX_COUNT); for (int f = 0; f < BOX_COUNT; f ++) mBoxes.push_back(nullptr); fillBoxes(); loadWindowState(); mUnequip = new Button(_("Unequip"), "unequip", this); const gcn::Rectangle &area = getChildrenArea(); mUnequip->setPosition(area.width - mUnequip->getWidth() - 5, area.height - mUnequip->getHeight() - 5); mUnequip->setEnabled(false); add(mPlayerBox); add(mUnequip); mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); mBorderColor = Theme::getThemeColor(Theme::BORDER); setForegroundColor(Theme::getThemeColor(Theme::TEXT)); }
CState::CState(const string filename, ivec3 &N, vec3 &L, double &interactionLength): nMovingAtoms(0), nMatrixAtoms(0), N(N), L(L), size(N%L) { if (load(filename)) // takes care of nAtoms, atoms, atomType and matrixAtom exit(1); makeBoxes(size, interactionLength); fillBoxes(); // cout << "atoms.size() = " << atoms.size() << endl; // cout << "nAtoms = " << nAtoms << endl; }
CState::CState(string atomType, string structure, ivec3 N, vec3 L, double interactionLength): // structure(structure), nMovingAtoms(0), nMatrixAtoms(0), N(N), L(L) { int atoms_per_site, sites_per_cell; mat r; // positions; if (structure == "fcc") { sites_per_cell = 4; atoms_per_site = 1; nSites = prod(N)*sites_per_cell; nAtoms = nSites*atoms_per_site; size = N%L; // for (int i = 0; i < nAtoms; i++) // { // elements.push_back(element); // } r << 0.0 << 0.0 << 0.0 << endr << 0.5 << 0.5 << 0.0 << endr << 0.0 << 0.5 << 0.5 << endr << 0.5 << 0.0 << 0.5 << endr; r.col(0) *= L(0); r.col(1) *= L(1); r.col(2) *= L(2); makeAtoms(N, L, r, sites_per_cell, atomType); makeBoxes(size, interactionLength); fillBoxes(); } else { cout << "Unknown structure" << endl; exit(1); } }
void CState::remove_half_the_atoms() { cout << "CState::remove_half_the_atoms" << endl; cout << "Old nAtoms = " << nAtoms << endl; cout << "Old nMovingAtoms = " << nMovingAtoms << endl; long idum = -1; for (int i = (nAtoms-1); i >= 0; i--) { if (!atoms[i]->matrixAtom && ran2(&idum) < 0.5) { delete atoms[i]; atoms.erase(atoms.begin() + i); } } nAtoms = atoms.size(); movingAtoms.clear(); nMovingAtoms = 0; for (int i = 0; i < nAtoms; i++) { if (!atoms[i]->matrixAtom) { movingAtoms.push_back(atoms[i]); nMovingAtoms++; } } if (movingAtoms.size() != nMovingAtoms) cout << "! Wrong number of moving atoms after removing half!" << endl; for (int i = 0; i < nBoxes; i++) { boxes[i]->flush(); } fillBoxes(); //// cout << "New nAtoms = " << nAtoms << endl; cout << "New nMovingAtoms = " << nMovingAtoms << endl; //// cout << "Exiting CState::remove_half_the_atoms" << endl << endl; }
EquipmentWindow::EquipmentWindow(Equipment *const equipment, Being *const being, const bool foring): // TRANSLATORS: equipment window name Window(_("Equipment"), false, nullptr, "equipment.xml"), gcn::ActionListener(), mEquipment(equipment), mItemPopup(new ItemPopup), mPlayerBox(new PlayerBox("equipment_playerbox.xml", "equipment_selectedplayerbox.xml")), // TRANSLATORS: equipment window button mUnequip(new Button(this, _("Unequip"), "unequip", this)), mSelected(-1), mForing(foring), mImageSet(nullptr), mBeing(being), mBoxes(), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), mBorderColor(getThemeColor(Theme::BORDER)), mLabelsColor(getThemeColor(Theme::LABEL)), mLabelsColor2(getThemeColor(Theme::LABEL_OUTLINE)), mSlotBackground(), mSlotHighlightedBackground(), mVertexes(new ImageCollection), mItemPadding(getOption("itemPadding")), mBoxSize(getOption("boxSize")), mButtonPadding(getOption("buttonPadding", 5)), mMinX(180), mMinY(345), mMaxX(0), mMaxY(0) { if (setupWindow) setupWindow->registerWindowForReset(this); if (!mBoxSize) mBoxSize = 36; // Control that shows the Player mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); if (foring) setWindowName("Being equipment"); else setWindowName("Equipment"); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); mBoxes.reserve(BOX_COUNT); for (int f = 0; f < BOX_COUNT; f ++) mBoxes.push_back(nullptr); fillBoxes(); recalcSize(); loadWindowState(); const gcn::Rectangle &area = getChildrenArea(); mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding, area.height - mUnequip->getHeight() - mButtonPadding); mUnequip->setEnabled(false); ImageRect rect; Theme::instance()->loadRect(rect, "equipment_background.xml", "", 0, 1); mSlotBackground = rect.grid[0]; mSlotHighlightedBackground = rect.grid[1]; add(mPlayerBox); add(mUnequip); enableVisibleSound(true); }
void game::newGame(){ //Create Sprites. fPlayer = new player(); fillBoxes(); ball = new bounceBall(); }