示例#1
0
SkillDialog::SkillDialog() :
    // TRANSLATORS: skills dialog name
    Window(_("Skills"), Modal_false, nullptr, "skills.xml"),
    ActionListener(),
    mSkills(),
    mDurations(),
    mTabs(CREATEWIDGETR(TabbedArea, this)),
    mDeleteTabs(),
    mPointsLabel(new Label(this, "0")),
    // TRANSLATORS: skills dialog button
    mUseButton(new Button(this, _("Use"), "use", this)),
    // TRANSLATORS: skills dialog button
    mIncreaseButton(new Button(this, _("Up"), "inc", this)),
    mDefaultModel(nullptr)
{
    setWindowName("Skills");
    setCloseButton(true);
    setResizable(true);
    setSaveVisible(true);
    setStickyButtonLock(true);
    setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    mUseButton->setEnabled(false);
    mIncreaseButton->setEnabled(false);

    place(0, 0, mTabs, 5, 5);
    place(0, 5, mPointsLabel, 4);
    place(3, 5, mUseButton);
    place(4, 5, mIncreaseButton);
}
示例#2
0
DebugWindow::DebugWindow():
    Window(_("Debug"), false, nullptr, "debug.xml")
{
    setWindowName("Debug");
    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    setDefaultSize(400, 300, ImageRect::CENTER);

    mTabs = new TabbedArea;
    mMapWidget = new MapDebugTab;
    mTargetWidget = new TargetDebugTab;
    mNetWidget = new NetDebugTab;

    mTabs->addTab(std::string(_("Map")), mMapWidget);
    mTabs->addTab(std::string(_("Target")), mTargetWidget);
    mTabs->addTab(std::string(_("Net")), mNetWidget);

    mTabs->setDimension(gcn::Rectangle(0, 0, 600, 300));
    add(mTabs);

    mMapWidget->resize(getWidth(), getHeight());
    mTargetWidget->resize(getWidth(), getHeight());
    mNetWidget->resize(getWidth(), getHeight());
    loadWindowState();
}
示例#3
0
WhoIsOnline::WhoIsOnline() :
    // TRANSLATORS: who is online window name
    Window(_("Who Is Online - Updating"), false, nullptr, "whoisonline.xml"),
    mThread(nullptr),
    mDownloadStatus(UPDATE_LIST),
    mDownloadComplete(true),
    mDownloadedBytes(0),
    mMemoryBuffer(nullptr),
    mCurlError(new char[CURL_ERROR_SIZE]),
    mBrowserBox(new BrowserBox(this)),
    mScrollArea(new ScrollArea(mBrowserBox, false)),
    mUpdateTimer(0),
    mOnlinePlayers(),
    mOnlineNicks(),
    // TRANSLATORS: who is online. button.
    mUpdateButton(new Button(this, _("Update"), "update", this)),
    mAllowUpdate(true),
    mShowLevel(false),
    mUpdateOnlineList(config.getBoolValue("updateOnlineList")),

    mGroupFriends(true)
{
    mCurlError[0] = 0;
    setWindowName("WhoIsOnline");

    const int h = 350;
    const int w = 200;
    setDefaultSize(w, h, ImageRect::CENTER);
    setVisible(false);
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);
    setSaveVisible(true);

    mUpdateButton->setEnabled(false);
    mUpdateButton->setDimension(gcn::Rectangle(5, 5, w - 10, 20 + 5));

    mBrowserBox->setOpaque(false);
    mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
    mScrollArea->setDimension(gcn::Rectangle(5, 20 + 10, w - 10, h - 10 - 30));
    mScrollArea->setSize(w - 10, h - 10 - 30);
    mBrowserBox->setLinkHandler(this);

    add(mUpdateButton);
    add(mScrollArea);

    setLocationRelativeTo(getParent());

    loadWindowState();
    enableVisibleSound(true);

    download();

    widgetResized(gcn::Event(nullptr));
    config.addListener("updateOnlineList", this);
    config.addListener("groupFriends", this);
    mGroupFriends = config.getBoolValue("groupFriends");
}
示例#4
0
MailWindow::MailWindow() :
    // TRANSLATORS: mail window name
    Window(_("Mail"), Modal_false, nullptr, "mail.xml"),
    ActionListener(),
    mMessages(),
    mMessagesMap(),
    mMailModel(new ExtendedNamesModel),
    mListBox(CREATEWIDGETR(ExtendedListBox,
        this, mMailModel, "extendedlistbox.xml")),
    mListScrollArea(new ScrollArea(this, mListBox,
        fromBool(getOptionBool("showlistbackground"), Opaque),
        "mail_listbackground.xml")),
    // TRANSLATORS: mail window button
    mRefreshButton(new Button(this, _("Refresh"), "refresh", this)),
    // TRANSLATORS: mail window button
    mNewButton(new Button(this, _("New"), "new", this)),
    // TRANSLATORS: mail window button
    mDeleteButton(new Button(this, _("Delete"), "delete", this)),
    // TRANSLATORS: mail window button
    mReturnButton(new Button(this, _("Return"), "return", this)),
    // TRANSLATORS: mail window button
    mOpenButton(new Button(this, _("Open"), "open", this))
{
    setWindowName("Mail");
    setCloseButton(true);
    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    setDefaultSize(310, 180, ImagePosition::CENTER);
    setMinWidth(310);
    setMinHeight(250);
    center();

    mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
    placer(4, 0, mRefreshButton);
    placer(4, 1, mOpenButton);
    placer(4, 2, mNewButton);
    placer(4, 3, mDeleteButton);
    placer(4, 4, mReturnButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    enableVisibleSound(true);
}
示例#5
0
DidYouKnowWindow::DidYouKnowWindow() :
    // TRANSLATORS: did you know window name
    Window(_("Did You Know?"), Modal_false, nullptr, "didyouknow.xml"),
    ActionListener(),
    mItemLinkHandler(new ItemLinkHandler),
    mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, Opaque_true,
        "browserbox.xml")),
    mScrollArea(new ScrollArea(this, mBrowserBox,
        Opaque_true, "didyouknow_background.xml")),
    // TRANSLATORS: did you know window button
    mButtonPrev(new Button(this, _("< Previous"), "prev", this)),
    // TRANSLATORS: did you know window button
    mButtonNext(new Button(this, _("Next >"), "next", this)),
    // TRANSLATORS: did you know window checkbox
    mOpenAgainCheckBox(new CheckBox(this, _("Auto open this window"),
        config.getBoolValue("showDidYouKnow"), this, "openagain"))
{
    setMinWidth(300);
    setMinHeight(220);
    setContentSize(455, 350);
    setWindowName("DidYouKnow");
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);
    setDefaultSize(500, 400, ImagePosition::CENTER);

    mBrowserBox->setOpaque(Opaque_false);
    // TRANSLATORS: did you know window button
    Button *const okButton = new Button(this, _("Close"), "close", this);

    mBrowserBox->setLinkHandler(mItemLinkHandler);
    if (gui)
        mBrowserBox->setFont(gui->getHelpFont());
    mBrowserBox->setProcessVars(true);
    mBrowserBox->setEnableImages(true);
    mBrowserBox->setEnableKeys(true);
    mBrowserBox->setEnableTabs(true);

    place(0, 0, mScrollArea, 5, 3).setPadding(3);
    place(0, 3, mOpenAgainCheckBox, 5);
    place(1, 4, mButtonPrev, 1);
    place(2, 4, mButtonNext, 1);
    place(4, 4, okButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    enableVisibleSound(true);
}
示例#6
0
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));
}
示例#7
0
HelpWindow::HelpWindow() :
    // TRANSLATORS: help window name
    Window(_("Help"), Modal_false, nullptr, "help.xml"),
    LinkHandler(),
    ActionListener(),
    // TRANSLATORS: help window. button.
    mDYKButton(new Button(this, _("Did you know..."), "DYK",
        BUTTON_SKIN, this)),
    mBrowserBox(new StaticBrowserBox(this, Opaque_true,
        "browserbox.xml")),
    mScrollArea(new ScrollArea(this, mBrowserBox,
        Opaque_true, "help_background.xml")),
    mTagFileMap()
{
    setMinWidth(300);
    setMinHeight(220);
    setContentSize(455, 350);
    setWindowName("Help");
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);

    if (setupWindow != nullptr)
        setupWindow->registerWindowForReset(this);

    setDefaultSize(500, 400, ImagePosition::CENTER, 0, 0);

    mBrowserBox->setOpaque(Opaque_false);

    mBrowserBox->setLinkHandler(this);
    if (gui != nullptr)
        mBrowserBox->setFont(gui->getHelpFont());
    mBrowserBox->setProcessVars(true);
    mBrowserBox->setEnableImages(true);
    mBrowserBox->setEnableKeys(true);
    mBrowserBox->setEnableTabs(true);

    place(4, 3, mDYKButton, 1, 1);
    place(0, 0, mScrollArea, 5, 3).setPadding(3);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    loadTags();
    enableVisibleSound(true);
    widgetResized(Event(nullptr));
}
示例#8
0
SetupWindow::SetupWindow() :
    // TRANSLATORS: setup window name
    Window(_("Setup"), false, nullptr, "setup.xml"),
    ActionListener(),
    mTabs(),
    mWindowsToReset(),
    mButtons(),
    mModsTab(nullptr),
    mResetWindows(nullptr),
    mPanel(new TabbedArea(this)),
    mVersion(new Label(this, FULL_VERSION))
{
    mPanel->postInit();
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);
}
示例#9
0
SetupWindow::SetupWindow() :
    // TRANSLATORS: setup window name
    Window(_("Setup"), Modal_false, nullptr, "setup.xml"),
    ActionListener(),
    mTabs(),
    mWindowsToReset(),
    mButtons(),
    mModsTab(nullptr),
    mQuickTab(nullptr),
    mResetWindows(nullptr),
    mPanel(CREATEWIDGETR(TabbedArea, this)),
    mVersion(new Label(this, FULL_VERSION)),
    mButtonPadding(5)
{
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);
}
示例#10
0
void WhoIsOnline::postInit()
{
    Window::postInit();
    const int h = 350;
    const int w = 200;
    setDefaultSize(w, h, ImagePosition::CENTER);

    setVisible(Visible_false);
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);
    setSaveVisible(true);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    mUpdateButton->setEnabled(false);
    mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5));

    mBrowserBox->setOpaque(Opaque_false);
    mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30));
    mScrollArea->setSize(w - 10, h - 10 - 30);
    mScrollArea->setSelectable(false);
    mBrowserBox->setLinkHandler(this);

    add(mUpdateButton);
    add(mScrollArea);

    setLocationRelativeTo(getParent());

    loadWindowState();
    enableVisibleSound(true);

    download();

    widgetResized(Event(nullptr));
    config.addListener("updateOnlineList", this);
    config.addListener("groupFriends", this);
    mGroupFriends = config.getBoolValue("groupFriends");
}
示例#11
0
DebugWindow::DebugWindow() :
    // TRANSLATORS: debug window name
    Window(_("Debug"), Modal_false, nullptr, "debug.xml"),
    mTabs(CREATEWIDGETR(TabbedArea, this)),
    mMapWidget(new MapDebugTab(this)),
    mTargetWidget(new TargetDebugTab(this)),
    mNetWidget(new NetDebugTab(this))
{
    setWindowName("Debug");
    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    setDefaultSize(400, 300, ImagePosition::CENTER);

    mTabs->setSelectable(false);
    mTabs->getWidgetContainer()->setSelectable(false);
    mTabs->getTabContainer()->setSelectable(false);
    // TRANSLATORS: debug window tab
    mTabs->addTab(std::string(_("Map")), mMapWidget);
    // TRANSLATORS: debug window tab
    mTabs->addTab(std::string(_("Target")), mTargetWidget);
    // TRANSLATORS: debug window tab
    mTabs->addTab(std::string(_("Net")), mNetWidget);

    mTabs->setDimension(Rect(0, 0, 600, 300));

    const int w = mDimension.width;
    const int h = mDimension.height;
    mMapWidget->resize(w, h);
    mTargetWidget->resize(w, h);
    mNetWidget->resize(w, h);
    loadWindowState();
    enableVisibleSound(true);
}
示例#12
0
ServerInfoWindow::ServerInfoWindow(ServerInfo &serverInfo) :
    // TRANSLATORS: servers dialog name
    Window(_("Server info"), Modal_false, nullptr, "serverinfo.xml"),
    LinkHandler(),
    mServerInfo(serverInfo),
    mBrowserBox(new StaticBrowserBox(this, Opaque_true,
        "browserbox.xml")),
    mScrollArea(new ScrollArea(this, mBrowserBox,
        Opaque_true, "serverinfo_background.xml"))
{
    setMinWidth(300);
    setMinHeight(220);
    setContentSize(455, 350);
    setWindowName("ServerInfoWindow");
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);

    setDefaultSize(500, 400, ImagePosition::CENTER, 0, 0);

    mBrowserBox->setOpaque(Opaque_false);
    mBrowserBox->setLinkHandler(this);
    if (gui != nullptr)
        mBrowserBox->setFont(gui->getHelpFont());
    mBrowserBox->setProcessVars(true);
    mBrowserBox->setEnableTabs(true);

    place(0, 0, mScrollArea, 5, 3).setPadding(3);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    enableVisibleSound(true);
    widgetResized(Event(nullptr));
}
示例#13
0
void BuyDialog::init()
{
    setWindowName("Buy");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setMinWidth(260);
    setMinHeight(220);
    setDefaultSize(260, 230, ImageRect::CENTER);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    mShopItems = new ShopItems;

    mShopItemList = new ShopListBox(this, mShopItems, mShopItems);
    mShopItemList->postInit();
    mScrollArea = new ScrollArea(this, mShopItemList,
        getOptionBool("showbackground"), "buy_background.xml");
    mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    mSlider = new Slider(this, 1.0, 1.0);
    mQuantityLabel = new Label(this, strprintf(
        "%d / %d", mAmountItems, mMaxItems));
    mQuantityLabel->setAlignment(Graphics::CENTER);
    // TRANSLATORS: buy dialog label
    mMoneyLabel = new Label(this, strprintf(
        _("Price: %s / Total: %s"), "", ""));

    mAmountField = new IntTextField(this, 1, 1, 123);
    mAmountField->setActionEventId("amount");
    mAmountField->addActionListener(this);
    mAmountField->setSendAlwaysEvents(true);
    mAmountField->setEnabled(false);

    // TRANSLATORS: buy dialog label
    mAmountLabel = new Label(this, _("Amount:"));
    mAmountLabel->adjustSize();

    // TRANSLATORS: This is a narrow symbol used to denote 'increasing'.
    // You may change this symbol if your language uses another.
    mIncreaseButton = new Button(this, _("+"), "inc", this);
    // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'.
    // You may change this symbol if your language uses another.
    mDecreaseButton = new Button(this, _("-"), "dec", this);
    // TRANSLATORS: buy dialog button
    mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId)
        ? _("Create") :_("Buy"), "buy", this);
    // TRANSLATORS: buy dialog button
    mQuitButton = new Button(this, _("Quit"), "quit", this);
    // TRANSLATORS: buy dialog button
    mAddMaxButton = new Button(this, _("Max"), "max", this);

    mDecreaseButton->adjustSize();
    mDecreaseButton->setWidth(mIncreaseButton->getWidth());

    mIncreaseButton->setEnabled(false);
    mDecreaseButton->setEnabled(false);
    mBuyButton->setEnabled(false);
    mSlider->setEnabled(false);

    mSlider->setActionEventId("slider");
    mSlider->addActionListener(this);

    mShopItemList->setDistributeMousePressed(false);
    mShopItemList->setActionEventId("buy");
    mShopItemList->addActionListener(this);
    mShopItemList->addSelectionListener(this);

    mFilterTextField->setWidth(100);

    ContainerPlacer placer = getPlacer(0, 0);
    placer(0, 0, mScrollArea, 9, 5).setPadding(3);
    placer(0, 5, mDecreaseButton);
    placer(1, 5, mSlider, 4);
    placer(5, 5, mIncreaseButton);
    placer(6, 5, mQuantityLabel, 2);
    placer(8, 5, mAddMaxButton);
    placer(0, 6, mAmountLabel, 2);
    placer(2, 6, mAmountField, 2);
    placer(0, 7, mMoneyLabel, 8);
    if (mSortDropDown)
    {
        placer(0, 8, mSortDropDown, 2);
    }
    else
    {
        // TRANSLATORS: buy dialog label
        mFilterLabel = new Label(this, _("Filter:"));
        mFilterLabel->adjustSize();
        placer(0, 8, mFilterLabel, 2);
    }
    placer(2, 8, mFilterTextField, 2);
    placer(7, 8, mBuyButton);
    placer(8, 8, mQuitButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    center();
    loadWindowState();
    enableVisibleSound(true);

    instances.push_back(this);
    setVisible(Visible_true);

    if (mSortDropDown)
        mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
}
示例#14
0
void SocialWindow::postInit()
{
    Window::postInit();
    setWindowName("Social");
    setVisible(Visible_false);
    setSaveVisible(true);
    setResizable(true);
    setSaveVisible(true);
    setCloseButton(true);
    setStickyButtonLock(true);

    setMinWidth(120);
    setMinHeight(55);
    setDefaultSize(590, 200, 180, 300);
    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    place(0, 0, mCreateButton);
    place(1, 0, mInviteButton);
    place(2, 0, mLeaveButton);
    place(0, 1, mCountLabel);
    place(0, 2, mTabs, 4, 4);

    widgetResized(Event(nullptr));

    loadWindowState();

    mTabs->addTab(mPlayers, mPlayers->mScroll);
    mTabs->addTab(mFriends, mFriends->mScroll);
    mTabs->addTab(mNavigation, mNavigation->mScroll);

    if (config.getBoolValue("enableAttackFilter"))
    {
        mAttackFilter = new SocialAttackTab(this,
            getOptionBool("showtabbackground"));
        mTabs->addTab(mAttackFilter, mAttackFilter->mScroll);
    }
    else
    {
        mAttackFilter = nullptr;
    }

    if (config.getBoolValue("enablePickupFilter"))
    {
        mPickupFilter = new SocialPickupTab(this,
            getOptionBool("showtabbackground"));
        mTabs->addTab(mPickupFilter, mPickupFilter->mScroll);
    }
    else
    {
        mPickupFilter = nullptr;
    }

    if (localPlayer && localPlayer->getParty())
        addTab(localPlayer->getParty());

    if (localPlayer && localPlayer->getGuild())
        addTab(localPlayer->getGuild());

    enableVisibleSound(true);
    updateButtons();
    player_relations.addListener(this);
}
示例#15
0
CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
                                   const int slot) :
    // TRANSLATORS: char create dialog name
    Window(_("New Character"), Modal_true, parent, "charcreate.xml"),
    ActionListener(),
    KeyListener(),
    mCharSelectDialog(parent),
    mNameField(new TextField(this, "")),
    // TRANSLATORS: char create dialog label
    mNameLabel(new Label(this, _("Name:"))),
    // TRANSLATORS: This is a narrow symbol used to denote 'next'.
    // You may change this symbol if your language uses another.
    // TRANSLATORS: char create dialog button
    mNextHairColorButton(new Button(this, _(">"), "nextcolor", this)),
    // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
    // You may change this symbol if your language uses another.
    // TRANSLATORS: char create dialog button
    mPrevHairColorButton(new Button(this, _("<"), "prevcolor", this)),
    // TRANSLATORS: char create dialog label
    mHairColorLabel(new Label(this, _("Hair color:"))),
    mHairColorNameLabel(new Label(this, "")),
    // TRANSLATORS: char create dialog button
    mNextHairStyleButton(new Button(this, _(">"), "nextstyle", this)),
    // TRANSLATORS: char create dialog button
    mPrevHairStyleButton(new Button(this, _("<"), "prevstyle", this)),
    // TRANSLATORS: char create dialog label
    mHairStyleLabel(new Label(this, _("Hair style:"))),
    mHairStyleNameLabel(new Label(this, "")),
    mNextRaceButton(nullptr),
    mPrevRaceButton(nullptr),
    mRaceLabel(nullptr),
    mRaceNameLabel(nullptr),
    mNextLookButton(nullptr),
    mPrevLookButton(nullptr),
    mLookLabel(nullptr),
    mLookNameLabel(nullptr),
    // TRANSLATORS: char create dialog button
    mActionButton(new Button(this, _("^"), "action", this)),
    // TRANSLATORS: char create dialog button
    mRotateButton(new Button(this, _(">"), "rotate", this)),
    mAttributeSlider(),
    mAttributeLabel(),
    mAttributeValue(),
    mAttributesLeft(new Label(this,
        // TRANSLATORS: char create dialog label
        strprintf(_("Please distribute %d points"), 99))),
    // TRANSLATORS: char create dialog button
    mCreateButton(new Button(this, _("Create"), "create", this)),
    // TRANSLATORS: char create dialog button
    mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
    mPlayer(new Being(BeingId_zero,
            ActorType::Player,
            BeingTypeId_zero,
            nullptr)),
    mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
        "charcreate_selectedplayerbox.xml")),
    mGenderStrip(nullptr),
    mMaxPoints(0),
    mUsedPoints(0),
    mRace(CharDB::getMinRace()),
    mLook(0),
    mMinLook(CharDB::getMinLook()),
    mMaxLook(CharDB::getMaxLook()),
    mMinRace(CharDB::getMinRace()),
    mMaxRace(CharDB::getMaxRace()),
    mHairStyle(0),
    mHairColor(0),
    mSlot(slot),
    mDefaultGender(Gender::FEMALE),
    mGender(Gender::UNSPECIFIED),
    maxHairColor(CharDB::getMaxHairColor()),
    minHairColor(CharDB::getMinHairColor()),
    maxHairStyle(CharDB::getMaxHairStyle()),
    minHairStyle(CharDB::getMinHairStyle()),
    mAction(0),
    mDirection(0)
{
    setStickyButtonLock(true);
    setSticky(true);
    setWindowName("NewCharacter");

    const int w = 480;
    const int h = 350;
    setContentSize(w, h);

    mPlayer->setGender(Gender::MALE);
    const std::vector<int> &items = CharDB::getDefaultItems();
    int i = 1;
    for (std::vector<int>::const_iterator it = items.begin(),
         it_end = items.end();
         it != it_end; ++ it, i ++)
    {
        mPlayer->setSprite(i, *it);
    }

    if (!maxHairColor)
        maxHairColor = ColorDB::getHairSize();
    if (!maxHairStyle)
        maxHairStyle = mPlayer->getNumOfHairstyles();

    if (maxHairStyle)
    {
        mHairStyle = (static_cast<unsigned int>(rand())
            % maxHairStyle) + minHairStyle;
    }
    else
    {
        mHairStyle = 0;
    }
    if (maxHairColor)
    {
        mHairColor = (static_cast<unsigned int>(rand())
            % maxHairColor) + minHairColor;
    }
    else
    {
        mHairColor = 0;
    }

    mNameField->setMaximum(24);

    if (serverFeatures->haveRaceSelection())
    {
        // TRANSLATORS: char create dialog button
        mNextRaceButton = new Button(this, _(">"), "nextrace", this);
        // TRANSLATORS: char create dialog button
        mPrevRaceButton = new Button(this, _("<"), "prevrace", this);
        // TRANSLATORS: char create dialog label
        mRaceLabel = new Label(this, _("Race:"));
        mRaceNameLabel = new Label(this, "");
    }
    if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
    {
        // TRANSLATORS: char create dialog button
        mNextLookButton = new Button(this, _(">"), "nextlook", this);
        // TRANSLATORS: char create dialog button
        mPrevLookButton = new Button(this, _("<"), "prevlook", this);
        // TRANSLATORS: char create dialog label
        mLookLabel = new Label(this, _("Look:"));
        mLookNameLabel = new Label(this, "");
    }

    if (serverFeatures->haveCreateCharGender())
    {
        const int size = config.getIntValue("fontSize");
        mGenderStrip = new TabStrip(this,
            "gender_" + getWindowName(),
            size + 16);
        mGenderStrip->setPressFirst(false);
        mGenderStrip->addActionListener(this);
        mGenderStrip->setActionEventId("gender_");
        // TRANSLATORS: one char size female character gender
        mGenderStrip->addButton(_("F"), "f", false);
        // TRANSLATORS: one char size male character gender
        mGenderStrip->addButton(_("M"), "m", false);
        // TRANSLATORS: one char size unknown character gender
        mGenderStrip->addButton(_("U"), "u", true);
        mGenderStrip->setVisible(Visible_true);
        add(mGenderStrip);

        mGenderStrip->setPosition(385, 130);
        mGenderStrip->setWidth(500);
        mGenderStrip->setHeight(50);
    }

    mPlayerBox->setWidth(74);

    mNameField->setActionEventId("create");
    mNameField->addActionListener(this);

    mPlayerBox->setDimension(Rect(360, 0, 110, 90));
    mActionButton->setPosition(385, 100);
    mRotateButton->setPosition(415, 100);

    mNameLabel->setPosition(5, 2);
    mNameField->setDimension(
            Rect(60, 2, 300, mNameField->getHeight()));

    const int leftX = 120;
    const int rightX = 300;
    const int labelX = 5;
    const int nameX = 145;
    int y = 30;

    mPrevHairColorButton->setPosition(leftX, y);
    mNextHairColorButton->setPosition(rightX, y);
    y += 5;
    mHairColorLabel->setPosition(labelX, y);
    mHairColorNameLabel->setPosition(nameX, y);
    y += 24;
    mPrevHairStyleButton->setPosition(leftX, y);
    mNextHairStyleButton->setPosition(rightX, y);
    y += 5;
    mHairStyleLabel->setPosition(labelX, y);
    mHairStyleNameLabel->setPosition(nameX, y);

    if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
    {
        y += 24;
        if (mPrevLookButton)
            mPrevLookButton->setPosition(leftX, y);
        if (mNextLookButton)
            mNextLookButton->setPosition(rightX, y);
        y += 5;
        if (mLookLabel)
            mLookLabel->setPosition(labelX, y);
        if (mLookNameLabel)
            mLookNameLabel->setPosition(nameX, y);  // 93
    }
    if (serverFeatures->haveRaceSelection())
    {
        y += 24;
        if (mPrevRaceButton)
            mPrevRaceButton->setPosition(leftX, y);
        if (mNextRaceButton)
            mNextRaceButton->setPosition(rightX, y);
        y += 5;
        if (mRaceLabel)
            mRaceLabel->setPosition(labelX, y);
        if (mRaceNameLabel)
            mRaceNameLabel->setPosition(nameX, y);
    }

    updateSliders();
    setButtonsPosition(w, h);

    add(mPlayerBox);
    add(mNameField);
    add(mNameLabel);
    add(mNextHairColorButton);
    add(mPrevHairColorButton);
    add(mHairColorLabel);
    add(mHairColorNameLabel);
    add(mNextHairStyleButton);
    add(mPrevHairStyleButton);
    add(mHairStyleLabel);
    add(mHairStyleNameLabel);
    add(mActionButton);
    add(mRotateButton);

    if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
    {
        add(mNextLookButton);
        add(mPrevLookButton);
        add(mLookLabel);
        add(mLookNameLabel);
    }

    if (serverFeatures->haveRaceSelection())
    {
        add(mNextRaceButton);
        add(mPrevRaceButton);
        add(mRaceLabel);
        add(mRaceNameLabel);
    }

    add(mAttributesLeft);
    add(mCreateButton);
    add(mCancelButton);

    center();
    setVisible(Visible_true);
    mNameField->requestFocus();

    updateHair();
    if (serverFeatures->haveRaceSelection())
        updateRace();
    if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
        updateLook();
    updatePlayer();

    addKeyListener(this);
}
示例#16
0
void TextSelectDialog::postInit()
{
    Window::postInit();
    setWindowName("TextSelectDialog");
    setResizable(true);
    setCloseButton(mAllowQuit == AllowQuit_true);
    setStickyButtonLock(true);
    setMinWidth(260);
    setMinHeight(220);
    setDefaultSize(260, 230, ImagePosition::CENTER, 0, 0);

    if (setupWindow != nullptr)
        setupWindow->registerWindowForReset(this);

    setActionEventId("OK");
    mModel = new NamesModel;
    mItemList = CREATEWIDGETR(ListBox,
        this,
        mModel,
        "listbox.xml");
    mScrollArea = new ScrollArea(this, mItemList,
        fromBool(getOptionBool("showbackground", false), Opaque),
        "sell_background.xml");
    mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    mSelectButton = new Button(this,
        mSelectButtonName,
        "select",
        BUTTON_SKIN,
        this);
    if (mAllowQuit == AllowQuit_true)
    {
        mQuitButton = new Button(this,
            // TRANSLATORS: sell dialog button
            _("Quit"),
            "quit",
            BUTTON_SKIN,
            this);
    }

    mSelectButton->setEnabled(false);

    mItemList->setDistributeMousePressed(false);
    mItemList->addSelectionListener(this);
    mItemList->setActionEventId("item");
    mItemList->addActionListener(this);

    ContainerPlacer placer(nullptr, nullptr);
    placer = getPlacer(0, 0);

    placer(0, 0, mScrollArea, 8, 5).setPadding(3);
    if (mQuitButton != nullptr)
    {
        placer(6, 5, mSelectButton, 1, 1);
        placer(7, 5, mQuitButton, 1, 1);
    }
    else
    {
        placer(7, 5, mSelectButton, 1, 1);
    }

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    center();
    loadWindowState();

    setVisible(Visible_true);
    enableVisibleSound(true);
}
示例#17
0
ShopWindow::ShopWindow() :
    // TRANSLATORS: shop window name
    Window(_("Personal Shop"), Modal_false, nullptr, "shop.xml"),
#ifdef EATHENA_SUPPORT
    VendingModeListener(),
    VendingSlotsListener(),
    BuyingStoreModeListener(),
    BuyingStoreSlotsListener(),
#endif
    ActionListener(),
    SelectionListener(),
    // TRANSLATORS: shop window button
    mCloseButton(new Button(this, _("Close"), "close", this)),
    mBuyShopItems(new ShopItems),
    mSellShopItems(new ShopItems),
    mTradeItem(nullptr),
    mBuyShopItemList(CREATEWIDGETR(ShopListBox,
        this, mBuyShopItems, mBuyShopItems)),
    mSellShopItemList(CREATEWIDGETR(ShopListBox,
        this, mSellShopItems, mSellShopItems)),
    mCurrentShopItemList(nullptr),
    mScrollArea(new ScrollArea(this, mBuyShopItemList,
        getOptionBool("showbuybackground"), "shop_buy_background.xml")),
    // TRANSLATORS: shop window label
    mAddButton(new Button(this, _("Add"), "add", this)),
    // TRANSLATORS: shop window label
    mDeleteButton(new Button(this, _("Delete"), "delete", this)),
    mAnnounceButton(nullptr),
    mPublishButton(nullptr),
    mRenameButton(nullptr),
    mAnnounceLinks(nullptr),
    mTabs(nullptr),
    mAcceptPlayer(),
    mTradeNick(),
    mSellShopName(serverConfig.getStringValue("sellShopName")),
    mSelectedItem(-1),
    mAnnonceTime(0),
    mLastRequestTimeList(0),
    mLastRequestTimeItem(0),
    mRandCounter(0),
    mTradeMoney(0),
    mSellShopSize(0),
    mBuyShopSize(0),
    isBuySelected(true),
    mHaveVending(serverFeatures->haveVending()),
    mEnableBuyingStore(false),
    mEnableVending(false)
{
    setWindowName("Personal Shop");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setMinWidth(300);
    setMinHeight(220);
    if (mainGraphics->mWidth > 600)
        setDefaultSize(500, 300, ImagePosition::CENTER);
    else
        setDefaultSize(380, 300, ImagePosition::CENTER);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    const int size = config.getIntValue("fontSize")
        + getOption("tabHeightAdjust", 16);
    mTabs = new TabStrip(this, "shop", size);
    mTabs->addActionListener(this);
    mTabs->setActionEventId("tab_");
    // TRANSLATORS: shop window tab name
    mTabs->addButton(_("Buy"), "buy", true);
    // TRANSLATORS: shop window tab name
    mTabs->addButton(_("Sell"), "sell", false);

    loadList();

    mBuyShopItemList->setPriceCheck(false);
    mSellShopItemList->setPriceCheck(false);

    mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    mBuyShopItemList->addSelectionListener(this);
    mSellShopItemList->addSelectionListener(this);

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    placer(0, 0, mTabs, 8).setPadding(3);

    if (mHaveVending)
    {
        // TRANSLATORS: shop window button
        mPublishButton = new Button(this, _("Publish"), "publish", this);
        // TRANSLATORS: shop window button
        mRenameButton = new Button(this, _("Rename"), "rename", this);
        placer(2, 6, mPublishButton);
        placer(3, 6, mRenameButton);
    }
    else
    {
        // TRANSLATORS: shop window button
        mAnnounceButton = new Button(this, _("Announce"), "announce", this);
        // TRANSLATORS: shop window checkbox
        mAnnounceLinks = new CheckBox(this, _("Show links in announce"), false,
            this, "link announce");

        placer(2, 6, mAnnounceButton);
        placer(0, 7, mAnnounceLinks, 7);
    }

    placer(0, 1, mScrollArea, 8, 5).setPadding(3);
    placer(0, 6, mAddButton);
    placer(1, 6, mDeleteButton);
    placer(7, 6, mCloseButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    center();
    loadWindowState();
#ifdef EATHENA_SUPPORT
    updateShopName();
#endif
    instances.push_back(this);
}
示例#18
0
KillStats::KillStats() :
    // TRANSLATORS: kill stats window name
    Window(_("Kill stats"), false, nullptr, "killstats.xml"),
    gcn::ActionListener(),
    mKillCounter(0),
    mExpCounter(0),
    mKillTCounter(0),
    mExpTCounter(0),
    mKillTimer(0),
    // TRANSLATORS: kill stats window button
    mResetButton(new Button(this, _("Reset stats"), "reset", this)),
    // TRANSLATORS: kill stats window button
    mTimerButton(new Button(this, _("Reset timer"), "timer", this)),
    mLine1(nullptr),
    mLine2(nullptr),
    mLine3(nullptr),
    // TRANSLATORS: kill stats window label
    mLine4(new Label(this, strprintf(_("Kills: %s, total exp: %s"),
        "?", "?"))),
    // TRANSLATORS: kill stats window label
    mLine5(new Label(this, strprintf(_("Avg Exp: %s"), "?"))),
    // TRANSLATORS: kill stats window label
    mLine6(new Label(this, strprintf(_("No. of avg mob to next level: %s"),
        "?"))),
    // TRANSLATORS: kill stats window label
    mLine7(new Label(this, strprintf(_("Kills/Min: %s, Exp/Min: %s"),
        "?", "?"))),
    mExpSpeed1Label(new Label(this, strprintf(ngettext(
        // TRANSLATORS: kill stats window label
        "Exp speed per %d min: %s", "Exp speed per %d min: %s", 1), 1, "?"))),
    mExpTime1Label(new Label(this, strprintf(ngettext(
        "Time for next level per %d min: %s",
        "Time for next level per %d min: %s", 1), 1, "?"))),
    mExpSpeed5Label(new Label(this, strprintf(ngettext(
        "Exp speed per %d min: %s", "Exp speed per %d min: %s", 5), 5, "?"))),
    mExpTime5Label(new Label(this, strprintf(ngettext(
        "Time for next level per %d min: %s",
        "Time for next level per %d min: %s", 5), 5, "?"))),
    mExpSpeed15Label(new Label(this, strprintf(ngettext(
        "Exp speed per %d min: %s", "Exp speed per %d min: %s", 15),
        15, "?"))),
    mExpTime15Label(new Label(this, strprintf(ngettext(
        "Time for next level per %d min: %s",
        "Time for next level per %d min: %s", 15), 15, "?"))),
    // TRANSLATORS: kill stats window label
    mLastKillExpLabel(new Label(this, strprintf("%s ?", _("Last kill exp:")))),
    mTimeBeforeJackoLabel(new Label(this, strprintf(
        // TRANSLATORS: kill stats window label
        "%s ?", _("Time before jacko spawn:")))),
    m1minExpTime(0),
    m1minExpNum(0),
    m1minSpeed(0),
    m5minExpTime(0),
    m5minExpNum(0),
    m5minSpeed(0),
    m15minExpTime(0),
    m15minExpNum(0),
    m15minSpeed(0),
    mJackoSpawnTime(0),
    mValidateJackoTime(0),
    mJackoId(0),
    mIsJackoAlive(false),
    mIsJackoMustSpawn(true),
    mIsJackoSpawnTimeUnknown(true)
{
    setWindowName("Kill stats");
    setCloseButton(true);
    setResizable(true);
    setSaveVisible(true);
    setStickyButtonLock(true);
    setDefaultSize(250, 250, 350, 300);

    listen(CHANNEL_ATTRIBUTES);
    const int xp(PlayerInfo::getAttribute(PlayerInfo::EXP));
    int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED));

    if (!xpNextLevel)
        xpNextLevel = 1;

    // TRANSLATORS: kill stats window label
    mLine1 = new Label(this, strprintf(_("Level: %d at %f%%"),
        player_node->getLevel(), static_cast<double>(xp)
        / static_cast<double>(xpNextLevel) * 100.0));

    // TRANSLATORS: kill stats window label
    mLine2 = new Label(this, strprintf(_("Exp: %d/%d Left: %d"),
        xp, xpNextLevel, xpNextLevel - xp));

    // TRANSLATORS: kill stats window label
    mLine3 = new Label(this, strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
        xpNextLevel / 100, "?"));

    place(0, 0, mLine1, 6).setPadding(0);
    place(0, 1, mLine2, 6).setPadding(0);
    place(0, 2, mLine3, 6).setPadding(0);
    place(0, 3, mLine4, 6).setPadding(0);
    place(0, 4, mLine5, 6).setPadding(0);
    place(0, 5, mLine6, 6).setPadding(0);
    place(0, 6, mLine7, 6).setPadding(0);

    place(0, 7, mLastKillExpLabel, 6).setPadding(0);
    place(0, 8, mTimeBeforeJackoLabel, 6).setPadding(0);
    place(0, 9, mExpSpeed1Label, 6).setPadding(0);
    place(0, 10, mExpTime1Label, 6).setPadding(0);
    place(0, 11, mExpSpeed5Label, 6).setPadding(0);
    place(0, 12, mExpTime5Label, 6).setPadding(0);
    place(0, 13, mExpSpeed15Label, 6).setPadding(0);
    place(0, 14, mExpTime15Label, 6).setPadding(0);

    place(5, 13, mTimerButton).setPadding(0);
    place(5, 14, mResetButton).setPadding(0);

    loadWindowState();
    enableVisibleSound(true);
}
示例#19
0
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);
}
示例#20
0
文件: setup.cpp 项目: koo5/manaplus
Setup::Setup() :
    // TRANSLATORS: setup window name
    Window(_("Setup"), false, nullptr, "setup.xml"),
    gcn::ActionListener(),
    mTabs(),
    mWindowsToReset(),
    mButtons(),
    mResetWindows(nullptr),
    mPanel(new TabbedArea(this)),
    mVersion(new Label(this, FULL_VERSION))
{
    setCloseButton(true);
    setResizable(true);
    setStickyButtonLock(true);

    int width = 620;
    const int height = 450;

    if (config.getIntValue("screenwidth") >= 730)
        width += 100;

    setContentSize(width, height);
    setMinWidth(310);
    setMinHeight(210);

    static const char *buttonNames[] =
    {
        // TRANSLATORS: setup button
        N_("Apply"),
        // TRANSLATORS: setup button
        N_("Cancel"),
        // TRANSLATORS: setup button
        N_("Store"),
        // TRANSLATORS: setup button
        N_("Reset Windows"),
        nullptr
    };
    int x = width;
    const int buttonPadding = getOption("buttonPadding", 5);
    for (const char ** curBtn = buttonNames; *curBtn; ++ curBtn)
    {
        Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
        mButtons.push_back(btn);
        x -= btn->getWidth() + buttonPadding;
        btn->setPosition(x, height - btn->getHeight() - buttonPadding);
        add(btn);

        // Store this button, as it needs to be enabled/disabled
        if (!strcmp(*curBtn, "Reset Windows"))
            mResetWindows = btn;
    }

    mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
    mPanel->enableScrollButtons(true);

    mTabs.push_back(new Setup_Video(this));
    mTabs.push_back(new Setup_Visual(this));
    mTabs.push_back(new Setup_Audio(this));
    mTabs.push_back(new Setup_Perfomance(this));
    mTabs.push_back(new Setup_Touch(this));
    mTabs.push_back(new Setup_Input(this));
    mTabs.push_back(new Setup_Joystick(this));
    mTabs.push_back(new Setup_Colors(this));
    mTabs.push_back(new Setup_Chat(this));
    mTabs.push_back(new Setup_Players(this));
    mTabs.push_back(new Setup_Relations(this));
    mTabs.push_back(new Setup_Theme(this));
    mTabs.push_back(new Setup_Other(this));

    FOR_EACH (std::list<SetupTab*>::const_iterator, i, mTabs)
    {
        SetupTab *const tab = *i;
        mPanel->addTab(tab->getName(), tab);
    }
示例#21
0
InventoryWindow::InventoryWindow(Inventory *const inventory) :
    Window("Inventory", Modal_false, nullptr, "inventory.xml"),
    ActionListener(),
    KeyListener(),
    SelectionListener(),
    InventoryListener(),
    AttributeListener(),
    mInventory(inventory),
    mItems(new ItemContainer(this, mInventory)),
    mUseButton(nullptr),
    mDropButton(nullptr),
    mOutfitButton(nullptr),
    mShopButton(nullptr),
    mCartButton(nullptr),
    mEquipmentButton(nullptr),
    mStoreButton(nullptr),
    mRetrieveButton(nullptr),
    mInvCloseButton(nullptr),
    mWeightBar(nullptr),
    mSlotsBar(new ProgressBar(this, 0.0F, 100, 0,
        ProgressColorId::PROG_INVY_SLOTS,
        "slotsprogressbar.xml", "slotsprogressbar_fill.xml")),
    mFilter(nullptr),
    mSortModel(new SortListModelInv),
    mSortDropDown(new DropDown(this, mSortModel, false,
        Modal_false, this, "sort")),
    mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
    mSortDropDownCell(nullptr),
    mNameFilterCell(nullptr),
    mFilterCell(nullptr),
    mSlotsBarCell(nullptr),
    mSplit(false),
    mCompactMode(false)
{
    mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR),
        getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE));

    if (inventory)
    {
        setCaption(gettext(inventory->getName().c_str()));
        setWindowName(inventory->getName());
        switch (inventory->getType())
        {
            case InventoryType::Inventory:
            case InventoryType::Trade:
            case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
            case InventoryType::Vending:
            case InventoryType::Mail:
            case InventoryType::Craft:
#endif
            case InventoryType::TypeEnd:
            default:
                mSortDropDown->setSelected(config.getIntValue(
                    "inventorySortOrder"));
                break;
            case InventoryType::Storage:
                mSortDropDown->setSelected(config.getIntValue(
                    "storageSortOrder"));
                break;
#ifdef EATHENA_SUPPORT
            case InventoryType::Cart:
                mSortDropDown->setSelected(config.getIntValue(
                    "cartSortOrder"));
                break;
#endif
        };
    }
    else
    {
        // TRANSLATORS: inventory window name
        setCaption(_("Inventory"));
        setWindowName("Inventory");
        mSortDropDown->setSelected(0);
    }

    if (setupWindow &&
        inventory &&
        inventory->getType() != InventoryType::Storage)
    {
        setupWindow->registerWindowForReset(this);
    }

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    if (mainGraphics->mWidth > 600)
        setDefaultSize(450, 310, ImagePosition::CENTER);
    else
        setDefaultSize(387, 307, ImagePosition::CENTER);
    setMinWidth(310);
    setMinHeight(179);
    addKeyListener(this);

    mItems->addSelectionListener(this);

    ScrollArea *const invenScroll = new ScrollArea(this, mItems,
        getOptionBool("showbackground"), "inventory_background.xml");
    invenScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    const int size = config.getIntValue("fontSize");
    mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16);
    mFilter->addActionListener(this);
    mFilter->setActionEventId("tag_");

    StringVect tags = ItemDB::getTags();
    const size_t sz = tags.size();
    for (size_t f = 0; f < sz; f ++)
        mFilter->addButton(tags[f], tags[f], false);

    if (!mInventory)
    {
        invInstances.push_back(this);
        return;
    }

    switch (mInventory->getType())
    {
        case InventoryType::Inventory:
        {
            // TRANSLATORS: inventory button
            const std::string equip = _("Equip");
            // TRANSLATORS: inventory button
            const std::string use = _("Use");
            // TRANSLATORS: inventory button
            const std::string unequip = _("Unequip");

            std::string longestUseString = getFont()->getWidth(equip) >
                getFont()->getWidth(use) ? equip : use;

            if (getFont()->getWidth(longestUseString) <
                getFont()->getWidth(unequip))
            {
                longestUseString = unequip;
            }

            mUseButton = new Button(this, longestUseString, "use", this);
            // TRANSLATORS: inventory button
            mDropButton = new Button(this, _("Drop..."), "drop", this);
            // TRANSLATORS: inventory outfits button
            mOutfitButton = new Button(this, _("O"), "outfit", this);
            // TRANSLATORS: inventory cart button
            mCartButton = new Button(this, _("C"), "cart", this);
            // TRANSLATORS: inventory shop button
            mShopButton = new Button(this, _("S"), "shop", this);
            // TRANSLATORS: inventory equipment button
            mEquipmentButton = new Button(this, _("E"), "equipment", this);
            mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
                ProgressColorId::PROG_WEIGHT,
                "weightprogressbar.xml", "weightprogressbar_fill.xml");
            mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
                getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));

            // TRANSLATORS: outfits button tooltip
            mOutfitButton->setDescription(_("Outfits"));
            // TRANSLATORS: cart button tooltip
            mCartButton->setDescription(_("Cart"));
            // TRANSLATORS: shop button tooltip
            mShopButton->setDescription(_("Shop"));
            // TRANSLATORS: equipment button tooltip
            mEquipmentButton->setDescription(_("Equipment"));

            place(0, 0, mWeightBar, 4);
            mSlotsBarCell = &place(4, 0, mSlotsBar, 4);
            mSortDropDownCell = &place(8, 0, mSortDropDown, 3);

            mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
            mNameFilterCell = &place(8, 1, mNameFilter, 3);

            place(0, 2, invenScroll, 11).setPadding(3);
            place(0, 3, mUseButton);
            place(1, 3, mDropButton);
            ContainerPlacer placer = getPlacer(10, 3);
            placer(0, 0, mShopButton);
            placer(1, 0, mOutfitButton);
            placer(2, 0, mCartButton);
            placer(3, 0, mEquipmentButton);

            updateWeight();
            break;
        }

        case InventoryType::Storage:
        {
            // TRANSLATORS: storage button
            mStoreButton = new Button(this, _("Store"), "store", this);
            // TRANSLATORS: storage button
            mRetrieveButton = new Button(this, _("Retrieve"),
                "retrieve", this);
            // TRANSLATORS: storage button
            mInvCloseButton = new Button(this, _("Close"), "close", this);

            mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
            mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

            mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
            mNameFilterCell = &place(6, 1, mNameFilter, 1);

            place(0, 2, invenScroll, 7, 4);
            place(0, 6, mStoreButton);
            place(1, 6, mRetrieveButton);
            place(6, 6, mInvCloseButton);
            break;
        }

#ifdef EATHENA_SUPPORT
        case InventoryType::Cart:
        {
            // TRANSLATORS: storage button
            mStoreButton = new Button(this, _("Store"), "store", this);
            // TRANSLATORS: storage button
            mRetrieveButton = new Button(this, _("Retrieve"),
                "retrieve", this);
            // TRANSLATORS: storage button
            mInvCloseButton = new Button(this, _("Close"), "close", this);

            mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
                ProgressColorId::PROG_WEIGHT,
                "weightprogressbar.xml", "weightprogressbar_fill.xml");
            mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
                getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));

            mSlotsBarCell = &place(3, 0, mSlotsBar, 3);
            mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

            mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
            mNameFilterCell = &place(6, 1, mNameFilter, 1);

            place(0, 0, mWeightBar, 3);
            place(0, 2, invenScroll, 7, 4);
            place(0, 6, mStoreButton);
            place(1, 6, mRetrieveButton);
            place(6, 6, mInvCloseButton);
            break;
        }
#endif

        default:
        case InventoryType::Trade:
        case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
        case InventoryType::Vending:
        case InventoryType::Mail:
        case InventoryType::Craft:
#endif
        case InventoryType::TypeEnd:
            break;
    };

    Layout &layout = getLayout();
    layout.setRowHeight(2, LayoutType::SET);

    mInventory->addInventoyListener(this);

    invInstances.push_back(this);

    if (inventory->isMainInventory())
    {
        updateDropButton();
    }
    else
    {
        if (!invInstances.empty())
            invInstances.front()->updateDropButton();
    }

    loadWindowState();
    enableVisibleSound(true);
}
示例#22
0
TradeWindow::TradeWindow():
    // TRANSLATORS: trade window caption
    Window(_("Trade: You"), false, nullptr, "trade.xml"),
    gcn::ActionListener(),
    gcn::SelectionListener(),
    mMyInventory(new Inventory(Inventory::TRADE)),
    mPartnerInventory(new Inventory(Inventory::TRADE)),
    mMyItemContainer(new ItemContainer(this, mMyInventory.get())),
    mPartnerItemContainer(new ItemContainer(this, mPartnerInventory.get())),
    // TRANSLATORS: trade window money label
    mMoneyLabel(new Label(this, strprintf(_("You get %s"), ""))),
    // TRANSLATORS: trade window button
    mAddButton(new Button(this, _("Add"), "add", this)),
    mOkButton(new Button(this, "", "", this)),  // Will be filled in later
    // TRANSLATORS: trade window money change button
    mMoneyChangeButton(new Button(this, _("Change"), "money", this)),
    mMoneyField(new TextField(this)),
    mStatus(PROPOSING),
    mAutoAddItem(nullptr),
    mAutoAddToNick(""),
    mGotMoney(0),
    mGotMaxMoney(0),
    mAutoMoney(0),
    mAutoAddAmount(0),
    mOkOther(false),
    mOkMe(false)
{
    logger->log1("TradeWindow::TradeWindow nick");

    setWindowName("Trade");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setDefaultSize(386, 180, ImageRect::CENTER);
    setMinWidth(310);
    setMinHeight(180);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    const gcn::Font *const fnt = mOkButton->getFont();
    int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
        fnt->getWidth(CAPTION_CONFIRMED));
    width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
    width = std::max(width, fnt->getWidth(CAPTION_ACCEPTED));

    mOkButton->setWidth(8 + width);

    mMyItemContainer->addSelectionListener(this);

    ScrollArea *const myScroll = new ScrollArea(mMyItemContainer,
        true, "trade_background.xml");
    myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    mPartnerItemContainer->addSelectionListener(this);

    ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer,
        true, "trade_background.xml");
    partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    // TRANSLATORS: trade window money label
    Label *const moneyLabel2 = new Label(this, _("You give:"));

    mMoneyField->setWidth(40);

    place(1, 0, mMoneyLabel);
    place(0, 1, myScroll).setPadding(3);
    place(1, 1, partnerScroll).setPadding(3);
    ContainerPlacer placer;
    placer = getPlacer(0, 0);
    placer(0, 0, moneyLabel2);
    placer(1, 0, mMoneyField, 2);
    placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
    placer = getPlacer(0, 2);
    placer(0, 0, mAddButton);
    placer(1, 0, mOkButton);
    Layout &layout = getLayout();
    layout.extend(0, 2, 2, 1);
    layout.setRowHeight(1, Layout::AUTO_SET);
    layout.setRowHeight(2, 0);
    layout.setColWidth(0, Layout::AUTO_SET);
    layout.setColWidth(1, Layout::AUTO_SET);

    loadWindowState();
    enableVisibleSound(true);

    reset();
}
示例#23
0
CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
    Window(_("New Character"), true, parent, "charcreate.xml"),
    mCharSelectDialog(parent),
    mRace(0),
    mSlot(slot),
    mAction(0),
    mDirection(0)
{
    setStickyButtonLock(true);
    setSticky(true);
    setWindowName("NewCharacter");

    mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr);
    mPlayer->setGender(GENDER_MALE);

    maxHairColor = CharDB::getMaxHairColor();
    minHairColor = CharDB::getMinHairColor();
    if (!maxHairColor)
        maxHairColor = ColorDB::getHairSize();

    maxHairStyle = CharDB::getMaxHairStyle();
    minHairStyle = CharDB::getMinHairStyle();
    if (!maxHairStyle)
        maxHairStyle = mPlayer->getNumOfHairstyles();

    mHairStyle = (rand() % maxHairStyle) + minHairStyle;
    mHairColor = (rand() % maxHairColor) + minHairColor;

    mNameField = new TextField("");
    mNameField->setMaximum(24);
    mNameLabel = new Label(_("Name:"));
    // TRANSLATORS: This is a narrow symbol used to denote 'next'.
    // You may change this symbol if your language uses another.
    mNextHairColorButton = new Button(_(">"), "nextcolor", this);
    // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
    // You may change this symbol if your language uses another.
    mPrevHairColorButton = new Button(_("<"), "prevcolor", this);
    mHairColorLabel = new Label(_("Hair color:"));
    mHairColorNameLabel = new Label("");
    mNextHairStyleButton = new Button(_(">"), "nextstyle", this);
    mPrevHairStyleButton = new Button(_("<"), "prevstyle", this);
    mHairStyleLabel = new Label(_("Hair style:"));
    mHairStyleNameLabel = new Label("");
    mActionButton = new Button(_("^"), "action", this);
    mRotateButton = new Button(_(">"), "rotate", this);

    if (serverVersion >= 2)
    {
        mNextRaceButton = new Button(_(">"), "nextrace", this);
        mPrevRaceButton = new Button(_("<"), "prevrace", this);
        mRaceLabel = new Label(_("Race:"));
        mRaceNameLabel = new Label("");
    }

    mCreateButton = new Button(_("Create"), "create", this);
    mCancelButton = new Button(_("Cancel"), "cancel", this);
    mMale = new RadioButton(_("Male"), "gender");
    mFemale = new RadioButton(_("Female"), "gender");
    mOther = new RadioButton(_("Other"), "gender");

    // Default to a Male character
    mMale->setSelected(true);

    mMale->setActionEventId("gender");
    mFemale->setActionEventId("gender");
    mOther->setActionEventId("gender");

    mMale->addActionListener(this);
    mFemale->addActionListener(this);
    mOther->addActionListener(this);

    mPlayerBox = new PlayerBox(mPlayer);
    mPlayerBox->setWidth(74);

    mNameField->setActionEventId("create");
    mNameField->addActionListener(this);

    mAttributesLeft = new Label(
            strprintf(_("Please distribute %d points"), 99));

    int w = 480;
    int h = 350;
    setContentSize(w, h);
    mPlayerBox->setDimension(gcn::Rectangle(350, 40, 110, 90));
    mActionButton->setPosition(375, 140);
    mRotateButton->setPosition(405, 140);

    mNameLabel->setPosition(5, 10);
    mNameField->setDimension(
            gcn::Rectangle(60, 10, 300, mNameField->getHeight()));

    int leftX = 120;
    int rightX = 300;
    int labelX = 5;
    int nameX = 145;
    mPrevHairColorButton->setPosition(leftX, 40);
    mNextHairColorButton->setPosition(rightX, 40);
    mHairColorLabel->setPosition(labelX, 45);
    mHairColorNameLabel->setPosition(nameX, 45);
    mPrevHairStyleButton->setPosition(leftX, 69);
    mNextHairStyleButton->setPosition(rightX, 69);
    mHairStyleLabel->setPosition(labelX, 74);
    mHairStyleNameLabel->setPosition(nameX, 74);

    if (serverVersion >= 2)
    {
        mPrevRaceButton->setPosition(leftX, 103);
        mNextRaceButton->setPosition(rightX, 103);
        mRaceLabel->setPosition(labelX, 108);
        mRaceNameLabel->setPosition(nameX, 108);
    }

    mAttributesLeft->setPosition(15, 280);
    updateSliders();
    mCancelButton->setPosition(
            w / 2,
            h - 5 - mCancelButton->getHeight());
    mCreateButton->setPosition(
            mCancelButton->getX() - 5 - mCreateButton->getWidth(),
            h - 5 - mCancelButton->getHeight());

    mMale->setPosition(30, 120);
    mFemale->setPosition(100, 120);
    mOther->setPosition(170, 120);

    add(mPlayerBox);
    add(mNameField);
    add(mNameLabel);
    add(mNextHairColorButton);
    add(mPrevHairColorButton);
    add(mHairColorLabel);
    add(mHairColorNameLabel);
    add(mNextHairStyleButton);
    add(mPrevHairStyleButton);
    add(mHairStyleLabel);
    add(mHairStyleNameLabel);
    add(mActionButton);
    add(mRotateButton);

    if (serverVersion >= 2)
    {
        add(mNextRaceButton);
        add(mPrevRaceButton);
        add(mRaceLabel);
        add(mRaceNameLabel);
    }

    add(mAttributesLeft);
    add(mCreateButton);
    add(mCancelButton);

    add(mMale);
    add(mFemale);
    add(mOther);

    center();
    setVisible(true);
    mNameField->requestFocus();

    updateHair();
    if (serverVersion >= 2)
        updateRace();

    updatePlayer();

    addKeyListener(this);
}
示例#24
0
InventoryWindow::InventoryWindow(Inventory *const inventory):
    Window("Inventory", false, nullptr, "inventory.xml"),
    gcn::ActionListener(),
    gcn::KeyListener(),
    gcn::SelectionListener(),
    InventoryListener(),
    mInventory(inventory),
    mItems(new ItemContainer(this, mInventory)),
    mWeight(),
    mSlots(),
    mUseButton(nullptr),
    mDropButton(nullptr),
    mSplitButton(nullptr),
    mOutfitButton(nullptr),
    mShopButton(nullptr),
    mEquipmentButton(nullptr),
    mStoreButton(nullptr),
    mRetrieveButton(nullptr),
    mInvCloseButton(nullptr),
    mWeightBar(nullptr),
    mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)),
    mFilter(nullptr),
    mSortModel(new SortListModelInv),
    mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")),
    mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
    mSortDropDownCell(nullptr),
    mNameFilterCell(nullptr),
    mFilterCell(nullptr),
    mSlotsBarCell(nullptr),
    mSplit(false),
    mCompactMode(false)
{
    if (inventory)
    {
        setCaption(gettext(inventory->getName().c_str()));
        setWindowName(inventory->getName());
    }
    else
    {
        // TRANSLATORS: inventory window name
        setCaption(_("Inventory"));
        setWindowName("Inventory");
    }

    listen(CHANNEL_ATTRIBUTES);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    setDefaultSize(387, 307, ImageRect::CENTER);
    setMinWidth(310);
    setMinHeight(179);
    addKeyListener(this);

    mItems->addSelectionListener(this);

    gcn::ScrollArea *const invenScroll = new ScrollArea(
        mItems, getOptionBool("showbackground"), "inventory_background.xml");
    invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);

    const int size = config.getIntValue("fontSize");
    mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16);
    mFilter->addActionListener(this);
    mFilter->setActionEventId("tag_");

    mSortDropDown->setSelected(0);

    StringVect tags = ItemDB::getTags();
    for (unsigned f = 0; f < tags.size(); f ++)
        mFilter->addButton(tags[f]);

    if (isMainInventory())
    {
        // TRANSLATORS: inventory button
        const std::string equip = _("Equip");
        // TRANSLATORS: inventory button
        const std::string use = _("Use");
        // TRANSLATORS: inventory button
        const std::string unequip = _("Unequip");

        std::string longestUseString = getFont()->getWidth(equip) >
            getFont()->getWidth(use) ? equip : use;

        if (getFont()->getWidth(longestUseString) <
            getFont()->getWidth(unequip))
        {
            longestUseString = unequip;
        }

        mUseButton = new Button(this, longestUseString, "use", this);
        // TRANSLATORS: inventory button
        mDropButton = new Button(this, _("Drop..."), "drop", this);
        // TRANSLATORS: inventory button
        mSplitButton = new Button(this, _("Split"), "split", this);
        // TRANSLATORS: inventory button
        mOutfitButton = new Button(this, _("Outfits"), "outfit", this);
        // TRANSLATORS: inventory button
        mShopButton = new Button(this, _("Shop"), "shop", this);
        // TRANSLATORS: inventory button
        mEquipmentButton = new Button(this, _("Equipment"), "equipment", this);
        mWeightBar = new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_WEIGHT);

        place(0, 0, mWeightBar, 4);
        mSlotsBarCell = &place(4, 0, mSlotsBar, 5);
        mSortDropDownCell = &place(9, 0, mSortDropDown, 2);

        mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
        mNameFilterCell = &place(9, 1, mNameFilter, 2);

        place(0, 2, invenScroll, 11).setPadding(3);
        place(0, 3, mUseButton);
        place(1, 3, mDropButton);
        place(8, 2, mSplitButton);
        place(8, 3, mShopButton);
        place(9, 3, mOutfitButton);
        place(10, 3, mEquipmentButton);

        updateWeight();
    }
    else
    {
        // TRANSLATORS: storage button
        mStoreButton = new Button(this, _("Store"), "store", this);
        // TRANSLATORS: storage button
        mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this);
        // TRANSLATORS: storage button
        mInvCloseButton = new Button(this, _("Close"), "close", this);

        mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
        mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

        mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
        mNameFilterCell = &place(6, 1, mNameFilter, 1);

        place(0, 2, invenScroll, 7, 4);
        place(0, 6, mStoreButton);
        place(1, 6, mRetrieveButton);
        place(6, 6, mInvCloseButton);
    }

    Layout &layout = getLayout();
    layout.setRowHeight(2, Layout::AUTO_SET);

    mInventory->addInventoyListener(this);

    invInstances.push_back(this);

    if (inventory && inventory->isMainInventory())
    {
        updateDropButton();
    }
    else
    {
        if (!invInstances.empty())
            invInstances.front()->updateDropButton();
    }

    loadWindowState();
    enableVisibleSound(true);
    slotsChanged(mInventory);

    widgetResized(gcn::Event(nullptr));
    if (!isMainInventory())
        setVisible(true);
}
示例#25
0
MailViewWindow::MailViewWindow(const MailMessage *const message) :
    // TRANSLATORS: mail view window name
    Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
    ActionListener(),
    mMessage(message),
    // TRANSLATORS: mail view window button
    mGetAttachButton(nullptr),
    // TRANSLATORS: mail view window button
    mCloseButton(new Button(this, _("Close"), "close", this)),
    mPrevButton(new Button(this, "<", "prev", this)),
    mNextButton(new Button(this, ">", "next", this)),
    // TRANSLATORS: mail view window button
    mReplyButton(new Button(this, _("Reply"), "reply", this)),
    // TRANSLATORS: mail view window label
    mTimeLabel(new Label(this, strprintf("%s %s", _("Time:"),
        message->strTime.c_str()))),
    mMoneyLabel(nullptr),
    // TRANSLATORS: mail view window label
    mFromLabel(new Label(this, strprintf("%s %s", _("From:"),
        message->sender.c_str()))),
    // TRANSLATORS: mail view window label
    mSubjectLabel(new Label(this, strprintf("%s %s", _("Subject:"),
        message->title.c_str()))),
    // TRANSLATORS: mail view window label
    mMessageLabel(new Label(this, strprintf("%s %s", _("Message:"),
        message->text.c_str()))),
    // TRANSLATORS: mail view window label
    mItemLabel(nullptr),
    mIcon(nullptr)
{
    setWindowName("MailView");
    setCloseButton(true);
    setResizable(true);
    setSaveVisible(false);
    setStickyButtonLock(true);
    setVisible(Visible_true);

    setDefaultSize(380, 230, ImageRect::CENTER);
    setMinWidth(200);
    setMinHeight(100);
    center();

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    int n = 0;
    placer(0, n++, mTimeLabel);
    placer(0, n++, mFromLabel);
    placer(0, n++, mSubjectLabel);
    if (message->money)
    {
        // TRANSLATORS: mail view window label
        mMoneyLabel = new Label(this, strprintf("%s %d", _("Money:"),
            message->money));
        placer(0, n++, mMoneyLabel);
    }
    placer(0, n++, mMessageLabel);
    if (message->itemId)
    {
        const ItemInfo &item = ItemDB::get(message->itemId);
        // +++ need use message->cards and ItemColorManager for colors
        Image *const image = resourceManager->getImage(combineDye2(
            paths.getStringValue("itemIcons").append(
            item.getDisplay().image),
            item.getDyeIconColorsString(ItemColor_one)));

        mIcon = new Icon(this, image);
        if (message->itemAmount != 1)
        {
            mItemLabel = new Label(this, std::string(_("Item:")).append(
                " (").append(toString(message->itemAmount)).append(") "));
        }
        else
        {
            mItemLabel = new Label(this, std::string(_("Item:")).append(" "));
        }
        placer(0, n, mItemLabel);
        placer(1, n++, mIcon);
    }
    if (message->money || message->itemId)
    {
        mGetAttachButton = new Button(this, _("Get attach"), "attach", this);
        placer(0, n++, mGetAttachButton);
    }
    ContainerPlacer placer2;
    placer2 = getPlacer(0, n);

    placer2(0, 0, mPrevButton);
    placer2(1, 0, mNextButton);
    placer2(3, 0, mReplyButton);
    placer2(4, 0, mCloseButton);

    loadWindowState();
    enableVisibleSound(true);
}
示例#26
0
NpcDialog::NpcDialog(const BeingId npcId) :
    // TRANSLATORS: npc dialog name
    Window(_("NPC"), Modal_false, nullptr, "npc.xml"),
    ActionListener(),
    mNpcId(npcId),
    mDefaultInt(0),
    mDefaultString(),
    mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP, true,
        "browserbox.xml")),
    mScrollArea(new ScrollArea(this, mTextBox,
        getOptionBool("showtextbackground"), "npc_textbackground.xml")),
    mText(),
    mNewText(),
    mItemList(CREATEWIDGETR(ExtendedListBox,
        this, this, "extendedlistbox.xml")),
    mListScrollArea(new ScrollArea(this, mItemList,
        getOptionBool("showlistbackground"), "npc_listbackground.xml")),
    mItems(),
    mImages(),
    mItemLinkHandler(new ItemLinkHandler),
    mTextField(new TextField(this, "")),
    mIntField(new IntTextField(this)),
    // TRANSLATORS: npc dialog button
    mPlusButton(new Button(this, _("+"), "inc", this)),
    // TRANSLATORS: npc dialog button
    mMinusButton(new Button(this, _("-"), "dec", this)),
    // TRANSLATORS: npc dialog button
    mClearButton(new Button(this, _("Clear"), "clear", this)),
    mButton(new Button(this, "", "ok", this)),
    // TRANSLATORS: npc dialog button
    mButton2(new Button(this, _("Close"), "close", this)),
    // TRANSLATORS: npc dialog button
    mButton3(new Button(this, _("Add"), "add", this)),
    // TRANSLATORS: npc dialog button
    mResetButton(new Button(this, _("Reset"), "reset", this)),
    mInventory(new Inventory(InventoryType::NPC, 1)),
    mItemContainer(new ItemContainer(this, mInventory)),
    mItemScrollArea(new ScrollArea(this, mItemContainer,
        getOptionBool("showitemsbackground"), "npc_listbackground.xml")),
    mInputState(NPC_INPUT_NONE),
    mActionState(NPC_ACTION_WAIT),
    mPlayerBox(new PlayerBox(nullptr)),
    mAvatarBeing(nullptr),
    mLastNextTime(0),
    mCameraMode(-1),
    mCameraX(0),
    mCameraY(0),
    mShowAvatar(false),
    mLogInteraction(config.getBoolValue("logNpcInGui"))
{
    // Basic Window Setup
    setWindowName("NpcText");
    setResizable(true);
    setFocusable(true);
    setStickyButtonLock(true);

    setMinWidth(200);
    setMinHeight(150);

    setDefaultSize(300, 578, ImageRect::LOWER_LEFT);

    mPlayerBox->setWidth(70);
    mPlayerBox->setHeight(100);

    // Setup output text box
    mTextBox->setOpaque(false);
    mTextBox->setMaxRow(config.getIntValue("ChatLogLength"));
    mTextBox->setLinkHandler(mItemLinkHandler);
    mTextBox->setProcessVars(true);
    mTextBox->setFont(gui->getNpcFont());
    mTextBox->setEnableKeys(true);
    mTextBox->setEnableTabs(true);

    mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);

    // Setup listbox
    mItemList->setWrappingEnabled(true);
    mItemList->setActionEventId("ok");
    mItemList->addActionListener(this);
    mItemList->setDistributeMousePressed(false);
    mItemList->setFont(gui->getNpcFont());
    if (gui->getNpcFont()->getHeight() < 20)
        mItemList->setRowHeight(20);
    else
        mItemList->setRowHeight(gui->getNpcFont()->getHeight());

    setContentSize(260, 175);
    mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mItemList->setVisible(Visible_true);
    mTextField->setVisible(Visible_true);
    mIntField->setVisible(Visible_true);

    const Font *const fnt = mButton->getFont();
    int width = std::max(fnt->getWidth(CAPTION_WAITING),
        fnt->getWidth(CAPTION_NEXT));
    width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
    width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
    mButton->setWidth(8 + width);

    // Place widgets
    buildLayout();

    center();
    loadWindowState();

    instances.push_back(this);
}
示例#27
0
QuestsWindow::QuestsWindow() :
    // TRANSLATORS: quests window name
    Window(_("Quests"), false, nullptr, "quests.xml"),
    ActionListener(),
    mQuestsModel(new QuestsModel),
    mQuestsListBox(new ExtendedListBox(this,
        mQuestsModel, "extendedlistbox.xml")),
    mQuestScrollArea(new ScrollArea(this, mQuestsListBox,
        getOptionBool("showlistbackground"), "quests_list_background.xml")),
    mItemLinkHandler(new ItemLinkHandler),
    mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")),
    mTextScrollArea(new ScrollArea(this, mText,
        getOptionBool("showtextbackground"), "quests_text_background.xml")),
    // TRANSLATORS: quests window button
    mCloseButton(new Button(this, _("Close"), "close", this)),
    mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")),
    mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")),
    mVars(),
    mQuests(),
    mAllEffects(),
    mMapEffects(),
    mNpcEffects(),
    mQuestLinks(),
    mNewQuestEffectId(paths.getIntValue("newQuestEffectId")),
    mCompleteQuestEffectId(paths.getIntValue("completeQuestEffectId")),
    mMap(nullptr)
{
    mQuestsListBox->postInit();

    setWindowName("Quests");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setSaveVisible(true);

    setDefaultSize(400, 350, ImageRect::RIGHT);
    setMinWidth(310);
    setMinHeight(220);

    mQuestsListBox->setActionEventId("select");
    mQuestsListBox->addActionListener(this);

    mQuestScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mText->setOpaque(false);
    mText->setLinkHandler(mItemLinkHandler);
    mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mQuestsListBox->setWidth(500);
    if (!gui || gui->getNpcFont()->getHeight() < 20)
        mQuestsListBox->setRowHeight(20);
    else
        mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    placer(0, 0, mQuestScrollArea, 4, 3).setPadding(3);
    placer(4, 0, mTextScrollArea, 4, 3).setPadding(3);
    placer(7, 3, mCloseButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    enableVisibleSound(true);
    loadXmlFile(paths.getStringValue("questsFile"));
    loadXmlFile(paths.getStringValue("questsPatchFile"));
    loadXmlDir("questsPatchDir", loadXmlFile);
}
示例#28
0
MailEditWindow::MailEditWindow() :
    // TRANSLATORS: mail edit window name
    Window(_("Edit mail"), Modal_false, nullptr, "mailedit.xml"),
    ActionListener(),
    // TRANSLATORS: mail edit window button
    mSendButton(new Button(this, _("Send"), "send", this)),
    // TRANSLATORS: mail edit window button
    mCloseButton(new Button(this, _("Close"), "close", this)),
    // TRANSLATORS: mail edit window button
    mAddButton(new Button(this, _("Add"), "add", this)),
    // TRANSLATORS: mail edit window label
    mToLabel(new Label(this, _("To:"))),
    // TRANSLATORS: mail edit window label
    mSubjectLabel(new Label(this, _("Subject:"))),
    // TRANSLATORS: mail edit window label
    mMoneyLabel(new Label(this, _("Money:"))),
    // TRANSLATORS: mail edit window label
    mItemLabel(new Label(this, _("Item:"))),
    // TRANSLATORS: mail edit window label
    mMessageLabel(new Label(this, _("Message:"))),
    mToField(new TextField(this)),
    mSubjectField(new TextField(this)),
    mMoneyField(new IntTextField(this, 0, 0, 10000000)),
    mMessageField(new TextField(this)),
    mInventory(new Inventory(InventoryType::MAIL, 1)),
    mItemContainer(new ItemContainer(this, mInventory)),
    mItemScrollArea(new ScrollArea(this, mItemContainer,
        getOptionBool("showitemsbackground"), "mailedit_listbackground.xml"))
{
    setWindowName("MailEdit");
    setCloseButton(true);
    setResizable(true);
    setCloseButton(true);
    setSaveVisible(false);
    setStickyButtonLock(true);
    setVisible(Visible_true);

    setDefaultSize(380, 200, ImageRect::CENTER);
    setMinWidth(200);
    setMinHeight(200);
    center();

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    mToField->setWidth(100);
    mSubjectField->setWidth(100);
    mMessageField->setWidth(100);
    mItemScrollArea->setHeight(70);

    mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mItemScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_NEVER);

    placer(0, 0, mToLabel);
    placer(1, 0, mToField, 3);
    placer(0, 1, mSubjectLabel);
    placer(1, 1, mSubjectField, 3);
    placer(0, 2, mMoneyLabel);
    placer(1, 2, mMoneyField, 3);
    placer(0, 3, mItemLabel);
    placer(1, 3, mItemScrollArea, 2, 2);
    placer(3, 4, mAddButton, 1);

    placer(0, 5, mMessageLabel);
    placer(1, 5, mMessageField, 3);
    placer(0, 6, mSendButton);
    placer(3, 6, mCloseButton);

    loadWindowState();
    enableVisibleSound(true);
}
示例#29
0
void SellDialog::postInit()
{
    setWindowName("Sell");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setMinWidth(260);
    setMinHeight(220);
    setDefaultSize(260, 230, ImagePosition::CENTER);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    // Create a ShopItems instance, that is aware of duplicate entries.
    mShopItems = new ShopItems(true);

    if (mAdvanced == Advanced_true)
        mShopItems->setMergeDuplicates(false);

    mShopItemList = CREATEWIDGETR(ShopListBox,
        this,
        mShopItems,
        mShopItems,
        ShopListBoxType::Unknown);
    mShopItemList->setProtectItems(true);
    mScrollArea = new ScrollArea(this, mShopItemList,
        fromBool(getOptionBool("showbackground"), Opaque),
        "sell_background.xml");
    mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    mSellButton = new Button(this,
        // TRANSLATORS: sell dialog button
        mAdvanced == Advanced_true ? _("Add") : _("Sell"),
        "presell",
        this);
    // TRANSLATORS: sell dialog button
    mQuitButton = new Button(this, _("Quit"), "quit", this);

    initButtons();

    mSellButton->setEnabled(false);

    mShopItemList->setDistributeMousePressed(false);
    mShopItemList->setPriceCheck(false);
    mShopItemList->addSelectionListener(this);
    mShopItemList->setActionEventId("sell");
    mShopItemList->addActionListener(this);

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    if (mIsSell == IsSell_true)
    {
        // TRANSLATORS: sell dialog button
        mIncreaseButton = new Button(this, _("+"), "inc", this);
        // TRANSLATORS: sell dialog button
        mDecreaseButton = new Button(this, _("-"), "dec", this);
        // TRANSLATORS: sell dialog button
        mAddMaxButton = new Button(this, _("Max"), "max", this);
        mSlider = new Slider(this, 1.0, 1.0);

        mQuantityLabel = new Label(this, strprintf(
            "%d / %d", mAmountItems, mMaxItems));
        mQuantityLabel->setAlignment(Graphics::CENTER);
        // TRANSLATORS: sell dialog label
        mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"),
            "", ""));
        if (mAdvanced == Advanced_true)
        {
            // TRANSLATORS: sell dialog button
            mConfirmButton = new Button(this, _("Sell"), "confirm", this);
            mConfirmButton->setEnabled(false);
        }

        mDecreaseButton->adjustSize();
        mDecreaseButton->setWidth(mIncreaseButton->getWidth());
        mIncreaseButton->setEnabled(false);
        mDecreaseButton->setEnabled(false);
        mSlider->setEnabled(false);
        mSlider->setActionEventId("slider");
        mSlider->addActionListener(this);

        placer(0, 0, mScrollArea, 8, 5).setPadding(3);
        placer(0, 5, mDecreaseButton);
        placer(1, 5, mSlider, 3);
        placer(4, 5, mIncreaseButton);
        placer(5, 5, mQuantityLabel, 2);
        placer(7, 5, mAddMaxButton);
        placer(0, 6, mMoneyLabel, 8);
        if (mAdvanced == Advanced_true)
        {
            placer(5, 7, mSellButton);
            placer(6, 7, mConfirmButton);
        }
        else
        {
            placer(6, 7, mSellButton);
        }
        placer(7, 7, mQuitButton);
    }
    else
    {
        placer(0, 0, mScrollArea, 8, 5).setPadding(3);
        placer(6, 5, mSellButton);
        placer(7, 5, mQuitButton);
    }

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    center();
    loadWindowState();

    instances.push_back(this);
    setVisible(Visible_true);
    enableVisibleSound(true);
}
示例#30
0
OutfitWindow::OutfitWindow() :
    // TRANSLATORS: outfits window name
    Window(_("Outfits"), Modal_false, nullptr, "outfits.xml"),
    ActionListener(),
    // TRANSLATORS: outfits window button
    mPreviousButton(new Button(this, _("<"), "previous", this)),
    // TRANSLATORS: outfits window button
    mNextButton(new Button(this, _(">"), "next", this)),
    // TRANSLATORS: outfits window button
    mEquipButtom(new Button(this, _("Equip"), "equip", this)),
    // TRANSLATORS: outfits window label
    mCurrentLabel(new Label(this, strprintf(_("Outfit: %d"), 1))),
    // TRANSLATORS: outfits window checkbox
    mUnequipCheck(new CheckBox(this, _("Unequip first"),
        serverConfig.getValueBool("OutfitUnequip0", true))),
    // TRANSLATORS: outfits window checkbox
    mAwayOutfitCheck(new CheckBox(this, _("Away outfit"),
        serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1))),
    // TRANSLATORS: outfits window label
    mKeyLabel(new Label(this, strprintf(_("Key: %s"),
        keyName(0).c_str()))),
    mBorderColor(getThemeColor(Theme::BORDER, 64)),
    mCurrentOutfit(0),
    mBoxWidth(33),
    mBoxHeight(33),
    mGridWidth(4),
    mGridHeight(4),
    mItems(),
    mAwayOutfit(0),
    mItemColors(),
    mItemClicked(false),
    mItemsUnequip()
{
    setWindowName("Outfits");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);

    mBackgroundColor = getThemeColor(Theme::BACKGROUND, 32);

    setDefaultSize(250, 400, 150, 290);
    setMinWidth(145);
    setMinHeight(220);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    mCurrentLabel->setAlignment(Graphics::CENTER);
    mKeyLabel->setAlignment(Graphics::CENTER);

    mUnequipCheck->setActionEventId("unequip");
    mUnequipCheck->addActionListener(this);

    mAwayOutfitCheck->setActionEventId("away");
    mAwayOutfitCheck->addActionListener(this);

    place(1, 3, mEquipButtom, 2);
    place(0, 4, mKeyLabel, 4);
    place(0, 5, mPreviousButton, 1);
    place(1, 5, mCurrentLabel, 2);
    place(3, 5, mNextButton, 1);
    place(0, 6, mUnequipCheck, 4);
    place(0, 7, mAwayOutfitCheck, 4);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);
    layout.setColWidth(4, Layout::CENTER);

    loadWindowState();

    enableVisibleSound(true);
    load();
}