Example #1
0
void CritterDialog::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(false);

    setPosition((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2 + Point(0, 291));

    auto background = new UI::Image("art/intrface/di_talk.frm");
    addUI("background", background);

    auto question = new UI::TextArea("question", 140, -55);
    question->setSize({370, 0});
    question->setWordWrap(true);
    addUI("question", question);

    // Interface buttons
    auto reviewButton = new UI::ImageButton(UI::ImageButton::Type::DIALOG_REVIEW_BUTTON, 13, 154);
    reviewButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onReviewButtonClick(dynamic_cast<Event::Mouse*>(event)); });
    addUI(reviewButton);

    auto barterButton = new UI::ImageButton(UI::ImageButton::Type::DIALOG_RED_BUTTON, 593, 40);
    barterButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onBarterButtonClick(dynamic_cast<Event::Mouse*>(event)); });
    addUI(barterButton);
}
        void CritterDialogReview::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(false);
            setModal(false);

            auto background = new UI::Image("art/intrface/review.frm");
            Point backgroundPos = Point((Game::getInstance()->renderer()->size() - background->size()) / 2);
            background->setPosition(backgroundPos);

            // Interface buttons
            auto doneButton = new UI::ImageButton(UI::ImageButton::Type::DIALOG_DONE_BUTTON, backgroundPos + Point(500, 398));
            doneButton->mouseClickHandler().add(std::bind(&CritterDialogReview::onDoneButtonClick, this, std::placeholders::_1));

            auto upButton = new UI::ImageButton(UI::ImageButton::Type::DIALOG_BIG_UP_ARROW, backgroundPos + Point(476, 154));
            upButton->mouseClickHandler().add(std::bind(&CritterDialogReview::onUpButtonClick, this, std::placeholders::_1));

            auto downButton = new UI::ImageButton(UI::ImageButton::Type::DIALOG_BIG_DOWN_ARROW, backgroundPos + Point(476, 192));
            downButton->mouseClickHandler().add(std::bind(&CritterDialogReview::onDownButtonClick, this, std::placeholders::_1));

            addUI(background);
            addUI(doneButton);
            addUI(upButton);
            addUI(downButton);
            auto list = new UI::TextAreaList(Point(88,76));
            list->setSize(Size(340,340));
            addUI("list",list);
        }
Example #3
0
void State::addUI(std::vector<UI*> uis)
{
    for (auto ui : uis)
    {
        addUI(ui);
    }
}
Example #4
0
 void State::addUI(const std::vector<UI::Base*>& uis)
 {
     for (auto ui : uis)
     {
         addUI(ui);
     }
 }
Example #5
0
void LoadGame::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(true);

    auto game = Game::getInstance();
    //auto player = Game::getInstance()->player();

    // background
    auto bg = new UI::Image("art/intrface/lsgame.frm");
    Point bgPos = Point((game->renderer()->size() - bg->size()) / 2);
    auto bgX = bgPos.x();
    auto bgY = bgPos.y();
    bg->setPosition(bgPos);
    addUI(bg);

    // BUTTONS

    // button: up arrow
    addUI("button_up", new UI::ImageButton(UI::ImageButton::Type::SMALL_UP_ARROW, bgX+35, bgY+58));
    // button: down arrow
    addUI("button_down", new UI::ImageButton(UI::ImageButton::Type::SMALL_DOWN_ARROW, bgX+35, bgY+72));

    // button: Done
    auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+391, bgY+349);
    doneButton->mouseClickHandler().add(std::bind(&LoadGame::onDoneButtonClick, this, std::placeholders::_1));
    addUI(doneButton);

    // button: Cancel
    auto cancelButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+495, bgY+349);
    cancelButton->mouseClickHandler().add([this](Event::Event* event){ this->doCancel(); });
    addUI(cancelButton);

    // LABELS

    auto font3_907824ff = ResourceManager::getInstance()->font("font3.aaf");
    SDL_Color color = {0x90, 0x78, 0x24, 0xff};

    // LOAD GAME LABEL
    auto saveGameLabel = new UI::TextArea(_t(MSG_LOAD_SAVE, 110), bgX+48, bgY+27);
    saveGameLabel->setFont(font3_907824ff, color);
    addUI(saveGameLabel);

    // DONE BUTTON LABEL
    auto doneButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 300), bgX+410, bgY+348);
    doneButtonLabel->setFont(font3_907824ff, color);
    addUI(doneButtonLabel);

    // CANCEL BUTTON LABEL
    auto cancelButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 121), bgX+515, bgY+348);
    cancelButtonLabel->setFont(font3_907824ff, color);
    addUI(cancelButtonLabel);
}
void CritterBarterState::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(true);

    setX((Game::getInstance()->renderer()->width() - 640)*0.5);
    setY((Game::getInstance()->renderer()->height() - 480)*0.5 + 291);

    addUI("background",new Image("art/intrface/barter.frm"));
    getActiveUI("background")->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &CritterBarterState::onBackgroundClick);

    addUI("offerButton", new ImageButton(ImageButton::TYPE_DIALOG_RED_BUTTON, 40, 162));

    addUI("talkButton", new ImageButton(ImageButton::TYPE_DIALOG_RED_BUTTON, 583, 162));
    getActiveUI("talkButton")->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &CritterBarterState::onTalkButtonClick);

    addUI("mineInventoryScrollUpButton",   new ImageButton(ImageButton::TYPE_DIALOG_UP_ARROW,   190, 56));
    addUI("mineInventoryScrollDownButton", new ImageButton(ImageButton::TYPE_DIALOG_DOWN_ARROW, 190, 82));

    addUI("theirsInventoryScrollUpButton",   new ImageButton(ImageButton::TYPE_DIALOG_UP_ARROW,   421, 56));
    addUI("theirsInventoryScrollDownButton", new ImageButton(ImageButton::TYPE_DIALOG_DOWN_ARROW, 421, 82));
}
Example #7
0
void Credits::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(true);

    Game::getInstance()->mouse()->pushState(Input::Mouse::Cursor::NONE);
    auto renderer = Game::getInstance()->renderer();
    setPosition(Point((renderer->size().width() - 640) / 2, renderer->size().height()));

    auto credits = ResourceManager::getInstance()->datFileItem("text/english/credits.txt");
    std::stringstream ss;
    credits->setPosition(0);
    ss << credits;
    std::string line;

    auto font_default = ResourceManager::getInstance()->font("font4.aaf", 0x907824ff);
    auto font_at = ResourceManager::getInstance()->font("font3.aaf", 0x706050ff);
    auto font_hash = ResourceManager::getInstance()->font("font4.aaf", 0x8c8c84ff);

    int y = 0;
    while (std::getline(ss, line))
    {
        Font* cur_font = font_default;
        int additionalGap = 0;
        if (line.find('\r') != std::string::npos)
        {
            line.erase(line.find('\r'));
        }
        if (line[0] == '#')
        {
            line.erase(line.begin());
            cur_font = font_hash;
        }
        else if (line[0] == '@')
        {
            line.erase(line.begin());
            cur_font = font_at;
            additionalGap = 6;
        }
        else if (line.empty())
        {
            line = "    ";
        }

        auto tx = new UI::TextArea(line, 0, y);
        tx->setFont(cur_font);
        tx->setSize({640, 0});
        tx->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);
        addUI(tx);
        _lines.push_back(tx);
        y += tx->textSize().height() + cur_font->verticalGap() + additionalGap;
    }
    _lastTicks=SDL_GetTicks();
}
Example #8
0
void Client::initToasts() {
  const auto TOAST_H = 40, TOAST_W = 200;

  auto x = (SCREEN_X - TOAST_W) / 2;
  _toasts = new List({x, 0, TOAST_W, SCREEN_Y}, TOAST_H);
  addUI(_toasts);

  populateToastsList();
}
void ExitConfirmState::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(false);

    auto background = new Image("art/intrface/lgdialog.frm");

    auto backgroundX = (Game::getInstance()->renderer()->width() - background->width())*0.5;
    auto backgroundY = (Game::getInstance()->renderer()->height() - background->height())*0.5;

    auto box1 = new Image("art/intrface/donebox.frm");
    auto box2 = new Image("art/intrface/donebox.frm");
    box1->setX(backgroundX+38);
    box1->setY(backgroundY+98);
    box2->setX(backgroundX+170);
    box2->setY(backgroundY+98);

    auto yesButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, backgroundX+50, backgroundY+102);
    auto noButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, backgroundX+183, backgroundY+102);
    yesButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &ExitConfirmState::onYesButtonClick);
    noButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &ExitConfirmState::onNoButtonClick);

    // label: Are you sure you want to quit?
    auto msg = ResourceManager::msgFileType("text/english/game/misc.msg");
    auto font = ResourceManager::font("font1.aaf", 0xb89c28ff);
    auto quitLabel = new TextArea(msg->message(0), backgroundX+30, backgroundY+52);
    quitLabel->setFont(font)->setWidth(244)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // label: yes & no
    auto msg2 = ResourceManager::msgFileType("text/english/game/dbox.msg");
    auto fontBig = ResourceManager::font("font3.aaf", 0xb89c28ff);
    // label: yes 101
    auto yesButtonLabel = new TextArea(msg2->message(101), backgroundX+74, backgroundY+101);
    yesButtonLabel->setFont(fontBig);
    // label: no 102
    auto noButtonLabel = new TextArea(msg2->message(102), backgroundX+204, backgroundY+101);
    noButtonLabel->setFont(fontBig);

    background->setX(backgroundX);
    background->setY(backgroundY);

    addUI(background);
    addUI(box1);
    addUI(box2);
    addUI(yesButton);
    addUI(noButton);
    addUI(quitLabel);
    addUI(yesButtonLabel);
    addUI(noButtonLabel);
}
Example #10
0
bool PauseLayer::init()
{
	if (!LayerColor::init())
		return false;

	initWithColor(Color4B(162, 162, 162, 128));

	addUI();
	addTouch();
	return true;
}
void PlayerEditAlertState::init()
{
    State::init();
    setFullscreen(false);
    setModal(true);

    auto bg = new Image("art/intrface/lgdialog.frm");

    auto bgX = (Game::getInstance()->renderer()->width() - 640)*0.5;
    auto bgY = (Game::getInstance()->renderer()->height() - 480)*0.5;

    bg->setX(bgX+164);
    bg->setY(bgY+173);

    auto font1_ff9f48ff = ResourceManager::font("font1.aaf", 0xff9f48ff);

    auto message = new TextArea(_message.c_str(), bgX+194, bgY+213);
    message->setWidth(250);
    message->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);
    message->setFont(font1_ff9f48ff);

    auto doneBox = new Image("art/intrface/donebox.frm");
    doneBox->setX(bgX+254);
    doneBox->setY(bgY+270);

    auto doneButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, bgX+264, bgY+273);
    doneButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &PlayerEditAlertState::onDoneButtonClick);

    auto msg = ResourceManager::msgFileType("text/english/game/editor.msg");
    auto doneLabel = new TextArea(msg->message(100), bgX+284, bgY+273);
    auto font3_b89c28ff = ResourceManager::font("font3.aaf", 0xb89c28ff);
    doneLabel->setFont(font3_b89c28ff);

    addUI(bg);
    addUI(message);
    addUI(doneBox);
    addUI(doneButton);
    addUI(doneLabel);
}
Example #12
0
void Container::init()
{
    if (_initialized) return;

    setModal(true);
    setFullscreen(false);

    auto game = Game::getInstance();

    setX((game->renderer()->width()  - 537)/2);
    setY((game->renderer()->height() - 376)/2);

    addUI("background", new Image("art/intrface/loot.frm"));

    addUI("button_done", new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 478, 331));
    getActiveUI("button_done")->addEventHandler("mouseleftclick", [this](Event* event){ this->onDoneButtonClick(dynamic_cast<MouseEvent*>(event)); });


    // TAKEALL
    // invmadn
    // invmaup

    // invupds
    // invupin
    // invupout


    auto dudeList = new ItemsList(170, 35);
    dudeList->setItems(Game::getInstance()->player()->inventory());
    addUI(dudeList);

    auto containerList = new ItemsList(292, 35);
    containerList->setItems(object()->inventory());
    addUI(containerList);

    dudeList->addEventHandler("itemdragstop", [containerList](Event* event){ containerList->onItemDragStop(dynamic_cast<MouseEvent*>(event)); });
    containerList->addEventHandler("itemdragstop", [dudeList](Event* event){ dudeList->onItemDragStop(dynamic_cast<MouseEvent*>(event)); });

}
Example #13
0
void Credits::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(true);

    Game::getInstance()->mouse()->pushState(Mouse::NONE);
    auto renderer = Game::getInstance()->renderer();
    setX((renderer->width()  - 640)*0.5);
    setY(renderer->height());

    auto credits = ResourceManager::datFileItem("text/english/credits.txt");
    std::stringstream ss;
    credits->setPosition(0);
    ss << credits;
    std::string line;

    auto font_default = ResourceManager::font("font4.aaf", 0x907824ff);
    auto font_at = ResourceManager::font("font3.aaf", 0x706050ff);
    auto font_hash = ResourceManager::font("font4.aaf", 0x8c8c84ff);

    int y = 0;
    while (std::getline(ss, line))
    {
        auto cur_font = font_default;
        if (line.find('\r')!=std::string::npos) line.erase(line.find('\r'));
        if (line[0]=='#')
        {
            line.erase(line.begin());
            cur_font = font_hash;
        }
        else if (line[0]=='@')
        {
            line.erase(line.begin());
            cur_font = font_at;
        }
        else if (line.empty())
        {
            line = "    ";
        }

        auto tx = new TextArea(line,0,y);
        tx->setFont(cur_font)->setWidth(640)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);
        addUI(tx);
        _lines.push_back(tx);
        y+=tx->height();
    }
    _lastTicks=SDL_GetTicks();
}
Example #14
0
void PlayerEditAge::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(true);

    Point backgroundPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
    int backgroundX = backgroundPos.x();
    int backgroundY = backgroundPos.y();

    auto bg = new UI::Image("art/intrface/charwin.frm");
    bg->setPosition(backgroundPos + Point(160, 0));

    auto ageBox = new UI::Image("art/intrface/agebox.frm");
    ageBox->setPosition(backgroundPos + Point(168, 10));

    auto doneBox = new UI::Image("art/intrface/donebox.frm");
    doneBox->setPosition(backgroundPos + Point(175, 40));

    auto decButton = new UI::ImageButton(UI::ImageButton::Type::LEFT_ARROW, backgroundX+178, backgroundY+14);
    decButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onDecButtonClick, this, std::placeholders::_1));

    auto incButton = new UI::ImageButton(UI::ImageButton::Type::RIGHT_ARROW, backgroundX+262, backgroundY+14);
    incButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onIncButtonClick, this, std::placeholders::_1));

    auto doneButton= new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, backgroundX+188, backgroundY+43);
    doneButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onDoneButtonClick, this, std::placeholders::_1));

    auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), backgroundX+210, backgroundY+43);

    doneLabel->setFont("font3.aaf", {0xb8, 0x9c, 0x28, 0xff});

    _counter = new UI::BigCounter(backgroundX+215, backgroundY+13);
    _counter->setNumber(Game::getInstance()->player()->age());

    addUI(bg);
    addUI(ageBox);
    addUI(doneBox);
    addUI(incButton);
    addUI(decButton);
    addUI(doneLabel);
    addUI(doneButton);
    addUI(_counter);

}
bool Inventory::init() {
	// 1. super init first
	if (!Layer::init()) {
		return false;
	}

	visibleSize = Director::getInstance()->getVisibleSize();
	origin = Director::getInstance()->getVisibleOrigin();

	addBackground(); // 添加背景
	addMenu(); // 添加菜单
	addUI(); // 添加UI
	// 每分钟更新一次时间
	this->schedule(schedule_selector(Inventory::updateTime), 60.0f, kRepeatForever, 0);
	return true;
}
Example #16
0
// on "init" you need to initialize your instance
bool MainScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
 	//load frames into cache
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("image/role.plist","image/role.pvr.ccz");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("image/ui.plist","image/ui.pvr.ccz");

	addRoles();
	addUI();
	addListener();
	addObserver();
    return true;
}
Example #17
0
        void CritterInteract::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(false);
            setModal(true);

            setPosition((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);

            addUI("background", new UI::Image("art/intrface/alltlk.frm"));

            // Centering camera on critter position
            auto locationState = Game::getInstance()->locationState();
            _oldCameraCenter = locationState->camera()->center();

            locationState->camera()->setCenter(critter()->hexagon()->position() + Point(0, 100));
        }
// on "init" you need to initialize your instance
bool Mainpage::init() {
    //////////////////////////////
    // 1. super init first
    if (!Layer::init()) {
        return false;
    }

    //visibleSize = Director::getInstance()->getVisibleSize();
    visibleSize = Global::getVisibleSize();
    origin = Director::getInstance()->getVisibleOrigin();

    preloadBGM(); // 预载入BGM
    addBackground(); // 添加背景
    addMenu(); // 添加菜单
    addUI(); // 添加UI
    // 播放bgm
    playBGM();

    // 每分钟更新一次时间
    this->schedule(schedule_selector(Mainpage::updateTime), 60.0f, kRepeatForever, 0);
    return true;
}
Example #19
0
void CritterDialog::addAnswer(const std::string& text)
{
    std::string line = "";
    line += 0x95;
    line += " ";
    line += text;

    int y = 50;
    for (auto answer : _answers)
    {
        y += answer->size().height() + 5;
    }

    auto answer = new UI::TextArea(line, 140, y);
    answer->setWordWrap(true);
    answer->setSize({370, 0});

    answer->addEventHandler("mousein", std::bind(&CritterDialog::onAnswerIn, this, std::placeholders::_1));
    answer->addEventHandler("mouseout", std::bind(&CritterDialog::onAnswerOut, this, std::placeholders::_1));
    answer->addEventHandler("mouseleftclick", std::bind(&CritterDialog::onAnswerClick, this, std::placeholders::_1));
    _answers.push_back(answer);
    addUI(answer);
}
void PlayerEditGender::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(true);

    Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
    int bgX = bgPos.x();
    int bgY = bgPos.y();

    auto bg = new UI::Image("art/intrface/charwin.frm");
    bg->setPosition(bgPos + Point(236, 0));

    _maleImage = new UI::ImageList((std::vector<std::string>){
                                    "art/intrface/maleoff.frm",
                                    "art/intrface/maleon.frm"
                                }, bgX+260, bgY+2);
    _maleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onMaleButtonPress(dynamic_cast<Event::Mouse*>(event)); });

    _femaleImage = new UI::ImageList((std::vector<std::string>){
                                                            "art/intrface/femoff.frm",
                                                            "art/intrface/femon.frm"
                                                            }, bgX+310, bgY+2);
    _femaleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onFemaleButtonPress(dynamic_cast<Event::Mouse*>(event)); });

    auto doneBox = new UI::Image("art/intrface/donebox.frm");
    doneBox->setPosition(bgPos + Point(250, 42));

    auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45);
    auto font3_b89c28ff = ResourceManager::getInstance()->font("font3.aaf", 0xb89c28ff);
    doneLabel->setFont(font3_b89c28ff);

    auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45);
    doneButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onDoneButtonClick(dynamic_cast<Event::Mouse*>(event)); });

    addUI(bg);
    addUI(doneBox);
    addUI(doneButton);
    addUI(doneLabel);
    addUI(_maleImage);
    addUI(_femaleImage);
    setGender(Game::getInstance()->player()->gender());
}
Example #21
0
        void PlayerEditGender::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(false);
            setModal(true);

            Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
            int bgX = bgPos.x();
            int bgY = bgPos.y();

            auto bg = new UI::Image("art/intrface/charwin.frm");
            bg->setPosition(bgPos + Point(236, 0));

            _maleImage = new UI::ImageList((std::vector<std::string>){
                                            "art/intrface/maleoff.frm",
                                            "art/intrface/maleon.frm"
                                        }, bgX+260, bgY+2);
            _maleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onMaleButtonPress, this, std::placeholders::_1));

            _femaleImage = new UI::ImageList((std::vector<std::string>){
                                                                    "art/intrface/femoff.frm",
                                                                    "art/intrface/femon.frm"
                                                                    }, bgX+310, bgY+2);
            _femaleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onFemaleButtonPress, this, std::placeholders::_1));

            auto doneBox = new UI::Image("art/intrface/donebox.frm");
            doneBox->setPosition(bgPos + Point(250, 42));

            auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45);
            doneLabel->setFont("font3.aaf", {0xb8, 0x9c, 0x28, 0xff});

            auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45);
            doneButton->mouseClickHandler().add(std::bind(&PlayerEditGender::onDoneButtonClick, this, std::placeholders::_1));

            addUI(bg);
            addUI(doneBox);
            addUI(doneButton);
            addUI(doneLabel);
            addUI(_maleImage);
            addUI(_femaleImage);
            setGender(Game::getInstance()->player()->gender());
        }
Example #22
0
void GameMenu::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(false);

    auto background = new UI::Image("art/intrface/opbase.frm");
    auto panelHeight = Game::getInstance()->locationState()->playerPanel()->size().height();

    auto backgroundPos = (Game::getInstance()->renderer()->size() - background->size() - Point(0, panelHeight)) / 2;
    int backgroundX = backgroundPos.x();
    int backgroundY = backgroundPos.y();

    auto saveGameButton    = new UI::ImageButton(UI::ImageButton::Type::OPTIONS_BUTTON, backgroundX+14, backgroundY+18);
    auto loadGameButton    = new UI::ImageButton(UI::ImageButton::Type::OPTIONS_BUTTON, backgroundX+14, backgroundY+18+37);
    auto preferencesButton = new UI::ImageButton(UI::ImageButton::Type::OPTIONS_BUTTON, backgroundX+14, backgroundY+18+37*2);
    auto exitGameButton    = new UI::ImageButton(UI::ImageButton::Type::OPTIONS_BUTTON, backgroundX+14, backgroundY+18+37*3);
    auto doneButton        = new UI::ImageButton(UI::ImageButton::Type::OPTIONS_BUTTON, backgroundX+14, backgroundY+18+37*4);

    preferencesButton->mouseClickHandler().add([this](Event::Event* event){ this->doPreferences(); });
    exitGameButton->mouseClickHandler().add(   [this](Event::Event* event){ this->doExit(); });
    doneButton->mouseClickHandler().add(       [this](Event::Event* event){ this->closeMenu(); });

    auto font = ResourceManager::getInstance()->font("font3.aaf", 0xb89c28ff);

    // label: save game
    auto saveGameButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 0), backgroundX+8, backgroundY+26);
    saveGameButtonLabel->setFont(font);
    saveGameButtonLabel->setSize({150, 0});
    saveGameButtonLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);
    saveGameButton->mouseClickHandler().add([this](Event::Event* event){ this->doSaveGame(); });

    // label: load game
    auto loadGameButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 1), backgroundX+8, backgroundY+26+37);
    loadGameButtonLabel->setFont(font);
    loadGameButtonLabel->setSize({150, 0});
    loadGameButtonLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);
    loadGameButton->mouseClickHandler().add([this](Event::Event* event){ this->doLoadGame(); });

    // label: preferences
    auto preferencesButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 2), backgroundX+8, backgroundY+26+37*2);
    preferencesButtonLabel->setFont(font);
    preferencesButtonLabel->setSize({150, 0});
    preferencesButtonLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);

    // label: exit game
    auto exitGameButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 3), backgroundX+8, backgroundY+26+37*3);
    exitGameButtonLabel->setFont(font);
    exitGameButtonLabel->setSize({150, 0});
    exitGameButtonLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);

    // label: done
    auto doneButtonLabel = new UI::TextArea(_t(MSG_OPTIONS, 4), backgroundX+8, backgroundY+26+37*4);
    doneButtonLabel->setFont(font);
    doneButtonLabel->setSize({150, 0});
    doneButtonLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);

    background->setPosition(backgroundPos);

    addUI(background);
    addUI(saveGameButton);
    addUI(loadGameButton);
    addUI(preferencesButton);
    addUI(exitGameButton);
    addUI(doneButton);
    addUI(saveGameButtonLabel);
    addUI(loadGameButtonLabel);
    addUI(preferencesButtonLabel);
    addUI(exitGameButtonLabel);
    addUI(doneButtonLabel);
}
Example #23
0
        void NewGame::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(true);
            setModal(true);

            auto renderer = Game::getInstance()->renderer();

            setPosition((renderer->size() - Point(640, 480)) / 2);

            addUI("background", new UI::Image("art/intrface/pickchar.frm"));

            auto beginGameButton = addUI(new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, 81, 322));
            beginGameButton->mouseClickHandler().add(std::bind(&NewGame::onBeginGameButtonClick, this, std::placeholders::_1));

            auto editButton = addUI(new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, 436, 319));
            editButton->mouseClickHandler().add(std::bind(&NewGame::onEditButtonClick, this, std::placeholders::_1));

            auto createButton = addUI(new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, 81, 424));
            createButton->mouseClickHandler().add(std::bind(&NewGame::onCreateButtonClick, this, std::placeholders::_1));

            auto backButton = addUI(new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, 461, 424));
            backButton->mouseClickHandler().add(std::bind(&NewGame::onBackButtonClick, this, std::placeholders::_1));

            auto prevCharacterButton = addUI(new UI::ImageButton(UI::ImageButton::Type::LEFT_ARROW, 292, 320));
            prevCharacterButton->mouseClickHandler().add(std::bind(&NewGame::onPrevCharacterButtonClick, this, std::placeholders::_1));

            auto nextCharacterButton = addUI(new UI::ImageButton(UI::ImageButton::Type::RIGHT_ARROW, 318, 320));
            nextCharacterButton->mouseClickHandler().add(std::bind(&NewGame::onNextCharacterButtonClick, this, std::placeholders::_1));

            addUI("images", new UI::ImageList({
                                            "art/intrface/combat.frm",
                                            "art/intrface/stealth.frm",
                                            "art/intrface/diplomat.frm"
                                            }, 27, 23));

            addUI("name", new UI::TextArea(300, 40));

            addUI("stats_1", new UI::TextArea(0, 70));
            getTextArea("stats_1")->setWidth(362);
            getTextArea("stats_1")->setHorizontalAlign(UI::TextArea::HorizontalAlign::RIGHT);

            addUI("stats_2", new UI::TextArea(374, 70));
            addUI("bio",     new UI::TextArea(437, 40));

            addUI("stats_3", new UI::TextArea(294, 150));
            getTextArea("stats_3")->setWidth(85);
            getTextArea("stats_3")->setHorizontalAlign(UI::TextArea::HorizontalAlign::RIGHT);

            addUI("stats3_values", new UI::TextArea(383, 150));
        }
Example #24
0
void PlayerEditName::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(true);

    Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
    int bgX = bgPos.x();
    int bgY = bgPos.y();

    _keyCodes.insert(std::make_pair(SDLK_a, 'a'));
    _keyCodes.insert(std::make_pair(SDLK_b, 'b'));
    _keyCodes.insert(std::make_pair(SDLK_c, 'c'));
    _keyCodes.insert(std::make_pair(SDLK_d, 'd'));
    _keyCodes.insert(std::make_pair(SDLK_e, 'e'));
    _keyCodes.insert(std::make_pair(SDLK_f, 'f'));
    _keyCodes.insert(std::make_pair(SDLK_g, 'g'));
    _keyCodes.insert(std::make_pair(SDLK_h, 'h'));
    _keyCodes.insert(std::make_pair(SDLK_i, 'i'));
    _keyCodes.insert(std::make_pair(SDLK_j, 'j'));
    _keyCodes.insert(std::make_pair(SDLK_k, 'k'));
    _keyCodes.insert(std::make_pair(SDLK_l, 'l'));
    _keyCodes.insert(std::make_pair(SDLK_m, 'm'));
    _keyCodes.insert(std::make_pair(SDLK_n, 'n'));
    _keyCodes.insert(std::make_pair(SDLK_o, 'o'));
    _keyCodes.insert(std::make_pair(SDLK_p, 'p'));
    _keyCodes.insert(std::make_pair(SDLK_q, 'q'));
    _keyCodes.insert(std::make_pair(SDLK_r, 'r'));
    _keyCodes.insert(std::make_pair(SDLK_s, 's'));
    _keyCodes.insert(std::make_pair(SDLK_t, 't'));
    _keyCodes.insert(std::make_pair(SDLK_u, 'u'));
    _keyCodes.insert(std::make_pair(SDLK_v, 'v'));
    _keyCodes.insert(std::make_pair(SDLK_w, 'w'));
    _keyCodes.insert(std::make_pair(SDLK_x, 'x'));
    _keyCodes.insert(std::make_pair(SDLK_y, 'y'));
    _keyCodes.insert(std::make_pair(SDLK_z, 'z'));
    _keyCodes.insert(std::make_pair(SDLK_1, '1'));
    _keyCodes.insert(std::make_pair(SDLK_2, '2'));
    _keyCodes.insert(std::make_pair(SDLK_3, '3'));
    _keyCodes.insert(std::make_pair(SDLK_4, '4'));
    _keyCodes.insert(std::make_pair(SDLK_5, '5'));
    _keyCodes.insert(std::make_pair(SDLK_6, '6'));
    _keyCodes.insert(std::make_pair(SDLK_7, '7'));
    _keyCodes.insert(std::make_pair(SDLK_8, '8'));
    _keyCodes.insert(std::make_pair(SDLK_9, '9'));
    _keyCodes.insert(std::make_pair(SDLK_0, '0'));

    _timer = SDL_GetTicks();

    auto bg = new UI::Image("art/intrface/charwin.frm");
    bg->setPosition(bgPos + Point(22, 0));

    auto nameBox = new UI::Image("art/intrface/namebox.frm");
    nameBox->setPosition(bgPos + Point(35, 10));

    auto doneBox = new UI::Image("art/intrface/donebox.frm");
    doneBox->setPosition(bgPos + Point(35, 40));

    auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+65, bgY+43);
    auto font3_b89c28ff = ResourceManager::getInstance()->font("font3.aaf", 0xb89c28ff);
    doneLabel->setFont(font3_b89c28ff);

    auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+45, bgY+43);
    doneButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onDoneButtonClick(dynamic_cast<Event::Mouse*>(event)); });

    _name = new UI::TextArea(Game::getInstance()->player()->name(), bgX+43, bgY+15);
    _name->addEventHandler("keydown", [this](Event::Event* event){ this->onTextAreaKeyDown(dynamic_cast<Event::Keyboard*>(event)); });

    _cursor = new UI::Image(5, 8);
    _cursor->setPosition(bgPos + Point(83, 15));
    _cursor->texture()->fill(0x3FF800FF);

    addUI(bg);
    addUI(nameBox);
    addUI(doneBox);
    addUI(doneLabel);
    addUI(doneButton);
    addUI(_name);
    addUI(_cursor);
}
Example #25
0
void NewGameState::init()
{
    if (_initialized) return;
    State::init();

    auto renderer = Game::getInstance()->renderer();

    setX((renderer->width()  - 640)*0.5);
    setY((renderer->height() - 480)*0.5);

    addUI("background", new Image("art/intrface/pickchar.frm"));

    auto beginGameButton = addUI(new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 81, 322));
    beginGameButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onBeginGameButtonClick);

    auto editButton = addUI(new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 436, 319));
    editButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onEditButtonClick);

    auto createButton = addUI(new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 81, 424));
    createButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onCreateButtonClick);

    auto backButton = addUI(new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 461, 424));
    backButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onBackButtonClick);

    auto prevCharacterButton = addUI(new ImageButton(ImageButton::TYPE_LEFT_ARROW, 292, 320));
    prevCharacterButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onPrevCharacterButtonClick);

    auto nextCharacterButton = addUI(new ImageButton(ImageButton::TYPE_RIGHT_ARROW, 318, 320));
    nextCharacterButton->addEventHandler("mouseleftclick", this, (EventRecieverMethod) &NewGameState::onNextCharacterButtonClick);

    addUI("images", new ImageList({
                                      "art/intrface/combat.frm",
                                      "art/intrface/stealth.frm",
                                      "art/intrface/diplomat.frm"
                                  }, 27, 23));

    addUI("name", new TextArea(300, 40));

    addUI("stats_1", new TextArea(0, 70));
    getTextArea("stats_1")->setWidth(362)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT);

    addUI("stats_2", new TextArea(374, 70));
    addUI("bio",     new TextArea(437, 40));

    addUI("stats_3", new TextArea(294, 150));
    getTextArea("stats_3")->setWidth(85)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT);

    addUI("stats3_values", new TextArea(383, 150));

    auto combat = new GameDudeObject();
    combat->loadFromGCDFile(ResourceManager::gcdFileType("premade/combat.gcd"));
    combat->setBiography(ResourceManager::bioFileType("premade/combat.bio")->text());
    _characters.push_back(combat);

    auto stealth = new GameDudeObject();
    stealth->loadFromGCDFile(ResourceManager::gcdFileType("premade/stealth.gcd"));
    stealth->setBiography(ResourceManager::bioFileType("premade/stealth.bio")->text());
    _characters.push_back(stealth);

    auto diplomat = new GameDudeObject();
    diplomat->loadFromGCDFile(ResourceManager::gcdFileType("premade/diplomat.gcd"));
    diplomat->setBiography(ResourceManager::bioFileType("premade/diplomat.bio")->text());
    _characters.push_back(diplomat);

    _changeCharacter();
}
Example #26
0
 UI::Base* State::addUI(const std::string& name, UI::Base* ui)
 {
     addUI(ui);
     _labeledUI.insert(std::pair<std::string, UI::Base*>(name, ui));
     return ui;
 }
Example #27
0
void SettingsMenu::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(true);

    // background
    auto background = new Image("art/intrface/prefscrn.frm");
    auto backgroundX = (Game::getInstance()->renderer()->width() - background->width())*0.5;
    auto backgroundY = (Game::getInstance()->renderer()->height() - background->height())*0.5;
    background->setX(backgroundX);
    background->setY(backgroundY);
    addUI(background);

    // Switches (big)
    auto combatDifficultySwitch = new MultistateImageButton(MultistateImageButton::TYPE_BIG_SWITCH, backgroundX+76, backgroundY+71);
    combatDifficultySwitch->setMaxState(3);
    combatDifficultySwitch->setState(Game::getInstance()->settings()->combatDifficulty());
    addUI("combat_difficulty",combatDifficultySwitch);

    auto gameDifficultySwitch = new MultistateImageButton(MultistateImageButton::TYPE_BIG_SWITCH, backgroundX+76, backgroundY+149);
    gameDifficultySwitch->setMaxState(3);
    gameDifficultySwitch->setState(Game::getInstance()->settings()->gameDifficulty());
    addUI("game_difficulty",gameDifficultySwitch);

    auto violenceLevelSwitch = new MultistateImageButton(MultistateImageButton::TYPE_BIG_SWITCH, backgroundX+76, backgroundY+227);
    violenceLevelSwitch->setState(Game::getInstance()->settings()->violenceLevel());
    addUI("violence_level",violenceLevelSwitch);

    auto targetHighlightSwitch = new MultistateImageButton(MultistateImageButton::TYPE_BIG_SWITCH, backgroundX+76, backgroundY+309);
    targetHighlightSwitch->setMaxState(3);
    targetHighlightSwitch->setState(Game::getInstance()->settings()->targetHighlight());
    addUI("target_highlight",targetHighlightSwitch);

    auto combatLooksSwitch = new MultistateImageButton(MultistateImageButton::TYPE_BIG_SWITCH, backgroundX+76, backgroundY+387);
    combatLooksSwitch->setMaxState(2);
    combatLooksSwitch->setState(Game::getInstance()->settings()->combatLooks());
    addUI("combat_looks",combatLooksSwitch);

    // Switches (small)
    auto combatMessagesSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74);
    combatMessagesSwitch->setState(Game::getInstance()->settings()->combatMessages());
    addUI("combat_messages",combatMessagesSwitch);

    auto combatTauntsSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74+66);
    combatTauntsSwitch->setState(Game::getInstance()->settings()->combatTaunts());
    addUI("combat_taunts",combatTauntsSwitch);

    auto languageFilterSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74+66*2);
    languageFilterSwitch->setState(Game::getInstance()->settings()->languageFilter());
    addUI("language_filter",languageFilterSwitch);

    auto runningSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74+66*3);
    runningSwitch->setState(Game::getInstance()->settings()->running());
    addUI("running",runningSwitch);

    auto subtitlesSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74+66*4);
    subtitlesSwitch->setState(Game::getInstance()->settings()->subtitles());
    addUI("subtitles",subtitlesSwitch);

    auto itemHightlightSwitch = new MultistateImageButton(MultistateImageButton::TYPE_SMALL_SWITCH, backgroundX+299, backgroundY+74+66*5);
    itemHightlightSwitch->setState(Game::getInstance()->settings()->itemHighlight());
    addUI("item_highlight",itemHightlightSwitch);

    // LABELS
    auto font1_907824ff = ResourceManager::font("font1.aaf", 0x907824ff);
    auto font3_907824ff = ResourceManager::font("font3.aaf", 0x907824ff);
    auto font4_907824ff = ResourceManager::font("font4.aaf", 0x907824ff);

    // GAME PREFERENCES
    _addTextArea(_t(MSG_OPTIONS, 100), backgroundX+74, backgroundY+10)->setFont(font4_907824ff);

    // COMBAT DIFFICULTY
    auto difficulty = _addTextArea(_t(MSG_OPTIONS, 102), backgroundX+21, backgroundY+48);
    difficulty->setWidth(158)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER)->setFont(font1_907824ff);

    // GAME DIFFICULTY
    _addTextArea(difficulty, backgroundX+21, backgroundY+48+77)->setText(_t(MSG_OPTIONS, 101));

    // VIOLENCE LEVEL
    _addTextArea(difficulty, backgroundX+21, backgroundY+48+156)->setText(_t(MSG_OPTIONS, 103));

    // TARGET HIGHLIGHT
    _addTextArea(difficulty, backgroundX+21, backgroundY+128+158)->setText(_t(MSG_OPTIONS, 104));

    // COMBAT LOOKS
    _addTextArea(difficulty, backgroundX+21, backgroundY+128+235)->setText(_t(MSG_OPTIONS, 105));

    // COMBAT MESSAGES
    auto combatMessages = _addTextArea(_t(MSG_OPTIONS, 106), backgroundX+206, backgroundY+49);
    combatMessages->setFont(font1_907824ff);

    // COMBAT TAUNTS
    _addTextArea(combatMessages, backgroundX+206, backgroundY+49+66)->setText(_t(MSG_OPTIONS, 107));

    // LANGUAGE FILTER
    _addTextArea(combatMessages, backgroundX+206, backgroundY+49+66*2)->setText(_t(MSG_OPTIONS, 108));

    // RUNNING
    _addTextArea(combatMessages, backgroundX+206, backgroundY+49+66*3)->setText(_t(MSG_OPTIONS, 109));

    // SUBTITLES
    _addTextArea(combatMessages, backgroundX+206, backgroundY+49+66*4)->setText(_t(MSG_OPTIONS, 110));

    // ITEM HIGHLIGHT
    _addTextArea(combatMessages, backgroundX+206, backgroundY+49+66*5)->setText(_t(MSG_OPTIONS, 111));

    // COMBAT SPEED
    auto combatSpeed = _addTextArea(_t(MSG_OPTIONS, 112), backgroundX+384, backgroundY+19);
    combatSpeed->setFont(font1_907824ff);

    // TEXT DELAY
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+95)->setText(_t(MSG_OPTIONS, 113));

    // MASTER AUDIO VOLUME
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165)->setText(_t(MSG_OPTIONS, 114));

    // MUSIC/MOVIE VOLUME
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165+51)->setText(_t(MSG_OPTIONS, 115));

    // SOUND EFFECTS VOLUME
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165+51*2)->setText(_t(MSG_OPTIONS, 116));

    // SPEECH VOLUME
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165+51*3)->setText(_t(MSG_OPTIONS, 117));

    // BRIGHTNESS LEVEL
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165+51*4)->setText(_t(MSG_OPTIONS, 118));

    // MOUSE SENSITIVITY
    _addTextArea(combatSpeed, backgroundX+384, backgroundY+165+51*5)->setText(_t(MSG_OPTIONS, 119));

    // DEFAULT BUTTON LABEL
    _addTextArea(combatSpeed, backgroundX+43, backgroundY+449)->setText(_t(MSG_OPTIONS, 120))->setFont(font3_907824ff);

    // DONE BUTTON LABEL
    _addTextArea(combatSpeed, backgroundX+169, backgroundY+449)->setText(_t(MSG_OPTIONS, 300))->setFont(font3_907824ff);

    // CANCEL BUTTON LABEL
    _addTextArea(combatSpeed, backgroundX+283, backgroundY+449)->setText(_t(MSG_OPTIONS, 121))->setFont(font3_907824ff);

    // COMBAT DIFFICULTY SWITCH LABELS
    _addTextArea(_t(MSG_OPTIONS, 203), backgroundX+43, backgroundY+81)->setFont(font1_907824ff);     // EASY
    _addTextArea(_t(MSG_OPTIONS, 204), backgroundX+68, backgroundY+67)->setFont(font1_907824ff);     // NORMAL
    _addTextArea(_t(MSG_OPTIONS, 205), backgroundX+122, backgroundY+81)->setFont(font1_907824ff);    // HARD

    // GAME DIFFICULTY SWITCH LABELS
    _addTextArea(_t(MSG_OPTIONS, 206), backgroundX+13, backgroundY+159)->setFont(font1_907824ff);    // WIMPY
    _addTextArea(_t(MSG_OPTIONS, 207), backgroundX+68, backgroundY+145)->setFont(font1_907824ff);    // NORMAL
    _addTextArea(_t(MSG_OPTIONS, 208), backgroundX+122, backgroundY+159)->setFont(font1_907824ff);   // ROUGH

    // VIOLENCE LEVEL SWITCH LABELS
    _addTextArea(_t(MSG_OPTIONS, 214), backgroundX+56, backgroundY+236)->setFont(font1_907824ff);    // NONE
    _addTextArea(_t(MSG_OPTIONS, 215), backgroundX+65, backgroundY+222)->setFont(font1_907824ff);    // MINIMUM
    _addTextArea(_t(MSG_OPTIONS, 207), backgroundX+122, backgroundY+236)->setFont(font1_907824ff);   // NORMAL
    _addTextArea(_t(MSG_OPTIONS, 216), backgroundX+122, backgroundY+257)->setFont(font1_907824ff)->setWidth(60); // MAXIMUM BLOOD

    // TARGET HIGHLIGHT SWITCH LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+42, backgroundY+319)->setFont(font1_907824ff);    // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+88, backgroundY+305)->setFont(font1_907824ff);    // ON
    _addTextArea(_t(MSG_OPTIONS, 213), backgroundX+122, backgroundY+319)->setFont(font1_907824ff)->setWidth(70)->setWordWrap(true); // TARGETING ONLY

    // COMBAT LOOKS SWITCH LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+42, backgroundY+397)->setFont(font1_907824ff);    // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+88, backgroundY+383)->setFont(font1_907824ff);    // ON

    // COMBAT MESSAGES SWITCH LABELS
    auto verboseLabel = _addTextArea(_t(MSG_OPTIONS, 211), backgroundX+203, backgroundY+69);         // VERBOSE
    verboseLabel->setFont(font1_907824ff)
                ->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT)
                ->setWidth(100);
    _addTextArea(_t(MSG_OPTIONS, 212), backgroundX+320, backgroundY+69)->setFont(font1_907824ff);    // BRIEF

    // COMBAT TAUNTS SWITCH LABELS
    _addTextArea(verboseLabel, backgroundX+203, backgroundY+69+67)->setText(_t(MSG_OPTIONS, 202)); // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+320, backgroundY+69+67)->setFont(font1_907824ff); // ON

    // LANGUAGE FILTER SWITCH LABELS
    _addTextArea(verboseLabel, backgroundX+203, backgroundY+69+67+66)->setText(_t(MSG_OPTIONS, 202)); // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+320, backgroundY+69+67+66)->setFont(font1_907824ff); // ON

    // RUNNING SWITCH LABELS
    _addTextArea(verboseLabel, backgroundX+203, backgroundY+69+67+66+64)->setText(_t(MSG_OPTIONS, 209)); // NORMAL
    _addTextArea(_t(MSG_OPTIONS, 219), backgroundX+320, backgroundY+69+67+66+64)->setFont(font1_907824ff); // ALWAYS

    // SUBTITLES SWITCH LABELS
    _addTextArea(verboseLabel, backgroundX+203, backgroundY+69+67+66+66+65)->setText(_t(MSG_OPTIONS, 202)); // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+320, backgroundY+69+66+67+66+65)->setFont(font1_907824ff); // OFF

    // ITEM HIGHLIGHT SWITCH LABELS
    _addTextArea(verboseLabel, backgroundX+203, backgroundY+69+67+66+64+65+68)->setText(_t(MSG_OPTIONS, 202)); // OFF
    _addTextArea(_t(MSG_OPTIONS, 201), backgroundX+320, backgroundY+69+64+67+66+65+68)->setFont(font1_907824ff); // ON

    // AFFECT PLAYER SPEECH
    _addTextArea(_t(MSG_OPTIONS, 122), backgroundX+405, backgroundY+72)->setFont(font1_907824ff);

    // COMBAT SPEED SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+384, backgroundY+38)->setFont(font1_907824ff);      // NORMAL
    auto fastestLabel = _addTextArea(_t(MSG_OPTIONS, 210), backgroundX+524, backgroundY+38);           // FASTEST
    fastestLabel->setFont(font1_907824ff)
            ->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT)
            ->setWidth(100);

    // TEXT DELAY SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 217), backgroundX+384, backgroundY+113)->setFont(font1_907824ff);     // SLOW
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+469, backgroundY+113)->setFont(font1_907824ff);     // NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+113)->setText(_t(MSG_OPTIONS, 218));       // FASTER

    // MASTER AUDIO VOLUME SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+384, backgroundY+184)->setFont(font1_907824ff);     // OFF
    _addTextArea(_t(MSG_OPTIONS, 221), backgroundX+450, backgroundY+184)->setFont(font1_907824ff);     // QUIET
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+494, backgroundY+184)->setFont(font1_907824ff);     // NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184)->setText(_t(MSG_OPTIONS, 222));       // LOUD

    // MUSIC/MOVIE VOLUME SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+384, backgroundY+184+51)->setFont(font1_907824ff);  // OFF
    _addTextArea(_t(MSG_OPTIONS, 221), backgroundX+450, backgroundY+184+51)->setFont(font1_907824ff);  // QUIET
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+494, backgroundY+184+51)->setFont(font1_907824ff);  // NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184+51)->setText(_t(MSG_OPTIONS, 222));    // LOUD

    // SOUND EFFECTS SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+384, backgroundY+184+51*2)->setFont(font1_907824ff);// OFF
    _addTextArea(_t(MSG_OPTIONS, 221), backgroundX+450, backgroundY+184+51*2)->setFont(font1_907824ff);// QUIET
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+494, backgroundY+184+51*2)->setFont(font1_907824ff);// NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184+51*2)->setText(_t(MSG_OPTIONS, 222));  // LOUD

    // SPEECH VOLUME SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 202), backgroundX+384, backgroundY+184+51*3)->setFont(font1_907824ff);// OFF
    _addTextArea(_t(MSG_OPTIONS, 221), backgroundX+450, backgroundY+184+51*3)->setFont(font1_907824ff);// QUIET
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+494, backgroundY+184+51*3)->setFont(font1_907824ff);// NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184+51*3)->setText(_t(MSG_OPTIONS, 222));  // LOUD

    // BRIGHTNESS LEVEL SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+384, backgroundY+184+51*4)->setFont(font1_907824ff);// NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184+51*4)->setText(_t(MSG_OPTIONS, 223));  // BRIGHTER

    // MOUSE SENSITIVITY SLIDER LABELS
    _addTextArea(_t(MSG_OPTIONS, 209), backgroundX+384, backgroundY+184+51*5)->setFont(font1_907824ff);// NORMAL
    _addTextArea(fastestLabel, backgroundX+524, backgroundY+184+51*5)->setText(_t(MSG_OPTIONS, 218));  // FASTER

    // BUTTONS

    // button: Default
    auto defaultButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, backgroundX+23, backgroundY+450);
    defaultButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onDefaultButtonClick(dynamic_cast<MouseEvent*>(event)); });
    addUI(defaultButton);

    // button: Done
    auto doneButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, backgroundX+148, backgroundY+450);
    doneButton->addEventHandler("mouseleftclick", [this](Event* event){ this->doSave(); });
    addUI(doneButton);

    // button: Cancel
    auto cancelButton = new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, backgroundX+263, backgroundY+450);
    cancelButton->addEventHandler("mouseleftclick", [this](Event* event){ this->doCancel(); });
    addUI(cancelButton);

    // button: Affect player speed
    auto affectPlayerSpeedCheckBox = new ImageButton(ImageButton::TYPE_CHECKBOX, backgroundX+383, backgroundY+68);
    affectPlayerSpeedCheckBox->setChecked(Game::getInstance()->settings()->playerSpeedup());
    addUI("player_speedup", affectPlayerSpeedCheckBox);

    // SLIDERS
    // COMBAT SPEED SLIDER
    auto combatSpeedSlider = new Slider(backgroundX+384, backgroundY+50);
    combatSpeedSlider->setMinValue(0.0);
    combatSpeedSlider->setMaxValue(50.0);
    combatSpeedSlider->setValue(Game::getInstance()->settings()->combatSpeed());
    addUI("combat_speed",combatSpeedSlider);

    // TEXT DELAY SLIDER
    auto textDelaySlider = new Slider(backgroundX+384, backgroundY+125);
    textDelaySlider->setValue(Game::getInstance()->settings()->textDelay());
    addUI("text_delay",textDelaySlider);

    // MASTER AUDIO VOLUME SLIDER
    auto masterAudioVolumeSlider = new Slider(backgroundX+384, backgroundY+196);
    masterAudioVolumeSlider->setValue(Game::getInstance()->settings()->masterVolume());
    addUI("master_volume", masterAudioVolumeSlider);

    // MUSIC VOLUME SLIDER
    auto musicVolumeSlider = new Slider(backgroundX+384, backgroundY+196+51);
    musicVolumeSlider->setValue(Game::getInstance()->settings()->musicVolume());
    addUI("music_volume", musicVolumeSlider);

    // SOUND EFFECTS VOLUME SLIDER
    auto soundEffectsVolumeSlider = new Slider(backgroundX+384, backgroundY+196+51*2);
    soundEffectsVolumeSlider->setValue(Game::getInstance()->settings()->sfxVolume());
    addUI("sfx_volume", soundEffectsVolumeSlider);

    // SPEECH VOLUME SLIDER
    auto speechVolumeSlider = new Slider(backgroundX+384, backgroundY+196+51*3);
    speechVolumeSlider->setValue(Game::getInstance()->settings()->voiceVolume());
    addUI("voice_volume", speechVolumeSlider);

    // BRIGHTNESS LEVEL SLIDER
    auto brightnessLevelSlider = new Slider(backgroundX+384, backgroundY+196+51*4);
    brightnessLevelSlider->setValue(Game::getInstance()->settings()->brightness());
    addUI("brightness", brightnessLevelSlider);

    // MOUSE SENSITIVITY SLIDER
    auto mouseSensitivitySlider = new Slider(backgroundX+384, backgroundY+196+51*5);
    mouseSensitivitySlider->setValue(Game::getInstance()->settings()->mouseSensitivity());
    addUI("mouse_sensitivity",mouseSensitivitySlider);
}
Example #28
0
TextArea* SettingsMenu::_addTextArea(TextArea* parent, unsigned int x, unsigned int y)
{
    auto textArea = new TextArea(parent, x, y);
    addUI(textArea);
    return textArea;
}
Example #29
0
TextArea* SettingsMenu::_addTextArea(std::string message, unsigned int x, unsigned int y)
{
    auto textArea = new TextArea(message, x, y);
    addUI(textArea);
    return textArea;
}
Example #30
0
void MainMenu::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(true);

    Game::getInstance()->mouse()->setState(Mouse::BIG_ARROW);

    auto renderer = Game::getInstance()->renderer();
    setX((renderer->width()  - 640)*0.5);
    setY((renderer->height() - 480)*0.5);

    addUI("background", new Image("art/intrface/mainmenu.frm"));

    // intro button
    auto introButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19));
    introButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onIntroButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // new game button
    auto newGameButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19 + 41));
    newGameButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onNewGameButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // load game button
    auto loadGameButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19 + 41*2));
    loadGameButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onLoadGameButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // settings button
    auto settingsButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19 + 41*3));
    settingsButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onSettingsButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // credits button
    auto creditsButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19 + 41*4));
    creditsButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onCreditsButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // exit button
    auto exitButton = addUI(new ImageButton(ImageButton::TYPE_MENU_RED_CIRCLE, 30, 19 + 41*5));
    exitButton->addEventHandler("mouseleftclick", [this](Event* event){ this->onExitButtonClick(dynamic_cast<MouseEvent*>(event)); });

    auto font4 = ResourceManager::font("font4.aaf", 0xb89c28ff);

    // "Intro" label
    auto introButtonLabel = new TextArea(_t(MSG_MISC, 9), 50, 20);
    introButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // "New Game" label
    auto newGameButtonLabel = new TextArea(_t(MSG_MISC, 10), 50, 20 + 41);
    newGameButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // "Load Game" label
    auto loadGameButtonLabel = new TextArea(_t(MSG_MISC, 11), 50, 20 + 41*2);
    loadGameButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // "Options" label
    auto optionsButtonLabel = new TextArea(_t(MSG_MISC, 12), 50, 20 + 41*3);
    optionsButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // "Credits" label
    auto creditsButtonLabel = new TextArea(_t(MSG_MISC, 13), 50, 20 + 41*4);
    creditsButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // "Exit" label
    auto exitButtonLabel = new TextArea(_t(MSG_MISC, 14), 50, 20 + 41*5);
    exitButtonLabel->setFont(font4)->setWidth(150)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_CENTER);

    // Text areas
    addUI(introButtonLabel);
    addUI(newGameButtonLabel);
    addUI(loadGameButtonLabel);
    addUI(optionsButtonLabel);
    addUI(creditsButtonLabel);
    addUI(exitButtonLabel);
}