Esempio n. 1
0
void TradeWindow::setMoney(const int amount)
{
    if (amount < 0 || amount < mGotMaxMoney)
    {
        if (config.getBoolValue("securetrades"))
        {
            close();
            return;
        }
        else
        {
            mMoneyLabel->setForegroundColorAll(getThemeColor(
                static_cast<int>(Theme::WARNING)), getThemeColor(
                static_cast<int>(Theme::WARNING_OUTLINE)));
        }
    }
    else
    {
        mMoneyLabel->setForegroundColorAll(getThemeColor(
            static_cast<int>(Theme::LABEL)), getThemeColor(
            static_cast<int>(Theme::LABEL_OUTLINE)));
        mGotMaxMoney = amount;
    }

    mGotMoney = amount;
    // TRANSLATORS: trade window money label
    mMoneyLabel->setCaption(strprintf(_("You get %s"),
                            Units::formatCurrency(amount).c_str()));
    mMoneyLabel->adjustSize();
}
Esempio n. 2
0
RadioButton::RadioButton(const Widget2 *const widget,
                         const std::string &caption, const std::string &group,
                         const bool marked):
    gcn::RadioButton(caption, group, marked),
    Widget2(widget),
    mHasMouse(false),
    mPadding(0),
    mImagePadding(0),
    mImageSize(9),
    mSpacing(2),
    mForegroundColor2(getThemeColor(Theme::RADIOBUTTON_OUTLINE))
{
    mForegroundColor = getThemeColor(Theme::RADIOBUTTON);
    if (instances == 0)
    {
        if (Theme::instance())
        {
            mSkin = Theme::instance()->load("radio.xml", "");
            updateAlpha();
        }
    }

    instances++;

    if (mSkin)
    {
        mPadding = mSkin->getPadding();
        mImagePadding = mSkin->getOption("imagePadding");
        mImageSize = mSkin->getOption("imageSize");
        mSpacing = mSkin->getOption("spacing");
    }

    adjustSize();
}
Esempio n. 3
0
ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
    Widget(widget),
    WidgetListener(),
    MouseListener(),
    mBackgroundImg(nullptr),
    mMaxItems(0),
    mBoxWidth(1),
    mBoxHeight(1),
    mGridWidth(1),
    mGridHeight(1),
    mVertexes(new ImageCollection)
{
    mAllowLogic = false;

    addMouseListener(this);
    addWidgetListener(this);

    mForegroundColor = getThemeColor(ThemeColorId::TEXT);
    mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);

    mBackgroundImg = Theme::getImageFromThemeXml(
        "item_shortcut_background.xml", "background.xml");

    if (mBackgroundImg)
    {
        mBackgroundImg->setAlpha(settings.guiAlpha);
        mBoxHeight = mBackgroundImg->getHeight();
        mBoxWidth = mBackgroundImg->getWidth();
    }
    else
    {
        mBoxHeight = 1;
        mBoxWidth = 1;
    }
}
Esempio n. 4
0
GuiTable::GuiTable(const Widget2 *const widget,
                   TableModel *const initial_model,
                   const bool opacity) :
    Widget(widget),
    MouseListener(),
    KeyListener(),
    mModel(nullptr),
    mTopWidget(nullptr),
    mActionListeners2(),
    mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
    mSelectedRow(-1),
    mSelectedColumn(-1),
    mLinewiseMode(false),
    mWrappingEnabled(false),
    mOpaque(opacity),
    mSelectable(true)
{
    mAllowLogic = false;
    mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);

    setModel(initial_model);
    setFocusable(true);

    addMouseListener(this);
    addKeyListener(this);
}
void SpellShortcutContainer::setSkin(const Widget2 *const widget,
                                     Skin *const skin)
{
    ShortcutContainer::setSkin(widget, skin);
    mForegroundColor = getThemeColor(ThemeColorId::TEXT, 255U);
    mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE, 255U);
}
Esempio n. 6
0
Tab::Tab(const Widget2 *const widget) :
    gcn::BasicContainer(),
    Widget2(widget),
    gcn::MouseListener(),
    gcn::WidgetListener(),
    mLabel(new Label(this)),
    mTabbedArea(nullptr),
    mTabColor(&getThemeColor(Theme::TAB)),
    mTabOutlineColor(&getThemeColor(Theme::TAB_OUTLINE)),
    mTabHighlightedColor(&getThemeColor(Theme::TAB_HIGHLIGHTED)),
    mTabHighlightedOutlineColor(&getThemeColor(
        Theme::TAB_HIGHLIGHTED_OUTLINE)),
    mTabSelectedColor(&getThemeColor(Theme::TAB_SELECTED)),
    mTabSelectedOutlineColor(&getThemeColor(Theme::TAB_SELECTED_OUTLINE)),
    mFlashColor(&getThemeColor(Theme::TAB_FLASH)),
    mFlashOutlineColor(&getThemeColor(Theme::TAB_FLASH_OUTLINE)),
    mPlayerFlashColor(&getThemeColor(Theme::TAB_PLAYER_FLASH)),
    mPlayerFlashOutlineColor(&getThemeColor(Theme::TAB_PLAYER_FLASH_OUTLINE)),
    mFlash(0),
    mVertexes(new ImageCollection),
    mImage(nullptr),
    mMode(0),
    mRedraw(true),
    mHasMouse(false)
{
    init();
}
Esempio n. 7
0
Desktop::Desktop(const Widget2 *const widget) :
    Container(widget),
    gcn::WidgetListener(),
    mWallpaper(nullptr),
    mVersionLabel(nullptr),
    mBackgroundColor(getThemeColor(Theme::BACKGROUND, 128)),
    mBackgroundGrayColor(getThemeColor(Theme::BACKGROUND_GRAY))
{
    addWidgetListener(this);

    Wallpaper::loadWallpapers();

    const std::string appName = branding.getValue("appName", std::string());
    if (appName.empty())
    {
        mVersionLabel = new Label(this, FULL_VERSION);
    }
    else
    {
        mVersionLabel = new Label(this, strprintf("%s (%s)", FULL_VERSION,
            appName.c_str()));
    }

    mVersionLabel->setBackgroundColor(getThemeColor(Theme::BACKGROUND, 128));
}
Esempio n. 8
0
ProgressBar::ProgressBar(const Widget2 *const widget,
                         float progress,
                         const int width,
                         const int height,
                         const ProgressColorIdT backColor,
                         const std::string &skin,
                         const std::string &skinFill) :
    Widget(widget),
    WidgetListener(),
    mFillRect(),
    mTextChunk(),
    mSkin(nullptr),
    mProgress(progress),
    mProgressToGo(progress),
    mBackgroundColorToGo(),
    mText(),
    mVertexes(new ImageCollection),
    mProgressPalette(backColor),
    mPadding(2),
    mFillPadding(3),
    mFillImage(false),
    mSmoothProgress(true),
    mSmoothColorChange(true),
    mTextChanged(true)
{
    mBackgroundColor = Theme::getProgressColor(
        backColor >= ProgressColorId::PROG_HP
        ? backColor : ProgressColorId::PROG_HP,
        mProgress);
    mBackgroundColorToGo = mBackgroundColor;
    mForegroundColor2 = getThemeColor(ThemeColorId::PROGRESS_BAR_OUTLINE);

    // The progress value is directly set at load time:
    if (mProgress > 1.0F || mProgress < 0.0F)
        mProgress = 1.0F;

    mForegroundColor = getThemeColor(ThemeColorId::PROGRESS_BAR);
    addWidgetListener(this);
    setSize(width, height);

    if (theme)
    {
        mSkin = theme->load(skin, "progressbar.xml");
        if (mSkin)
        {
            setPadding(mSkin->getPadding());
            mFillPadding = mSkin->getOption("fillPadding");
            mFillImage = mSkin->getOption("fillImage") != 0;
            if (mFillImage)
                theme->loadRect(mFillRect, skinFill, "progressbar_fill.xml");
        }
        setHeight(2 * mPadding + getFont()->getHeight() + 2);
    }

    mInstances++;
}
Esempio n. 9
0
void TradeWindow::clear()
{
    mAutoAddItem = nullptr;
    mAutoAddToNick.clear();
    mAutoMoney = 0;
    mAutoAddAmount = 0;
    mGotMoney = 0;
    mGotMaxMoney = 0;
    mMoneyLabel->setForegroundColorAll(getThemeColor(
        static_cast<int>(Theme::LABEL)), getThemeColor(
        static_cast<int>(Theme::LABEL_OUTLINE)));
}
Esempio n. 10
0
ListBox::ListBox(const Widget2 *const widget,
                 ListModel *const listModel,
                 const std::string &skin) :
    Widget(widget),
    MouseListener(),
    KeyListener(),
    mSelected(-1),
    mListModel(listModel),
    mWrappingEnabled(false),
    mSelectionListeners(),
    mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT, 255U)),
    mForegroundSelectedColor(getThemeColor(ThemeColorId::LISTBOX_SELECTED,
        255U)),
    mForegroundSelectedColor2(getThemeColor(
        ThemeColorId::LISTBOX_SELECTED_OUTLINE, 255U)),
    mOldSelected(-1),
    mPadding(0),
    mPressedIndex(-2),
    mRowHeight(0),
    mItemPadding(1),
    mSkin(nullptr),
    mDistributeMousePressed(true),
    mCenterText(false)
{
    setWidth(100);
    setFocusable(true);
    addMouseListener(this);
    addKeyListener(this);

    mForegroundColor = getThemeColor(ThemeColorId::LISTBOX, 255U);
    mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE, 255U);

    if (theme != nullptr)
    {
        mSkin = theme->load(skin,
            "listbox.xml",
            true,
            Theme::getThemePath());
    }

    if (mSkin != nullptr)
    {
        mPadding = mSkin->getPadding();
        mItemPadding = mSkin->getOption("itemPadding");
    }

    const Font *const font = getFont();
    mRowHeight = CAST_U32(
        font->getHeight() + 2 * mItemPadding);
}
Esempio n. 11
0
ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
                                             const unsigned number) :
    ShortcutContainer(widget),
    mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED, 255U)),
    mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE, 255U)),
    mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED, 255U)),
    mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE,
        255U)),
    mNumber(number),
    mKeyOffsetX(2),
    mKeyOffsetY(2),
    mItemClicked(false)
{
    mMaxItems = ItemShortcut::getItemCount();
}
Esempio n. 12
0
void TextPopup::postInit()
{
    const int fontHeight = getFont()->getHeight();
    int y = 0;
    for (int f = 0; f < TEXTPOPUPCOUNT; f ++)
    {
        Label *const label = new Label(this);
        mText[f] = label;
        label->setPosition(0, y);
        label->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
        add(label);
        y += fontHeight;
    }
    addMouseListener(this);
}
Esempio n. 13
0
SpellPopup::SpellPopup():
    Popup("SpellPopup", "spellpopup.xml"),
    mItemName(new Label(this)),
    mItemComment(new Label(this))
{
    mItemName->setFont(boldFont);
    mItemName->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mItemComment->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));

    add(mItemName);
    add(mItemComment);

    addMouseListener(this);
}
Esempio n. 14
0
SpeechBubble::SpeechBubble() :
    Popup("Speech", "speechbubble.xml"),
    mText(),
    mSpacing(mSkin ? mSkin->getOption("spacing") : 2),
    mCaption(new Label(this)),
    mSpeechBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
        "speechbrowserbox.xml"))
{
    setContentSize(140, 46);
    setMinWidth(8);
    setMinHeight(8);

    mCaption->setFont(boldFont);
    mSpeechBox->setOpaque(false);
    mSpeechBox->setForegroundColorAll(getThemeColor(ThemeColorId::BUBBLE_TEXT),
        getThemeColor(ThemeColorId::BUBBLE_TEXT_OUTLINE));
}
Esempio n. 15
0
void TradeWindow::reset()
{
    mMyInventory->clear();
    mPartnerInventory->clear();
    mOkOther = false;
    mOkMe = false;
    setMoney(0);
    mMoneyField->setEnabled(true);
    mMoneyField->setText("");
    mMoneyLabel->setForegroundColorAll(getThemeColor(
        static_cast<int>(Theme::LABEL)), getThemeColor(
        static_cast<int>(Theme::LABEL_OUTLINE)));
    mAddButton->setEnabled(true);
    mMoneyChangeButton->setEnabled(true);
    mGotMoney = 0;
    mGotMaxMoney = 0;
    setStatus(PREPARING);
}
Esempio n. 16
0
EmoteShortcutContainer::EmoteShortcutContainer():
    ShortcutContainer(),
    mEmoteImg(),
    mEmotePopup(new TextPopup),
    mForegroundColor2(getThemeColor(Theme::TEXT_OUTLINE)),
    mEmoteClicked(false),
    mEmoteMoved(0)
{
    addMouseListener(this);
    addWidgetListener(this);

    mBackgroundImg = Theme::getImageFromThemeXml(
        "item_shortcut_background.xml", "background.xml");

    if (mBackgroundImg)
        mBackgroundImg->setAlpha(Client::getGuiAlpha());

    // Setup emote sprites
    for (int i = 0; i <= EmoteDB::getLast(); i++)
    {
        const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
        if (sprite && sprite->sprite)
            mEmoteImg.push_back(sprite);
    }

    mMaxItems = MAX_ITEMS;

    if (mBackgroundImg)
    {
        mBoxHeight = mBackgroundImg->getHeight();
        mBoxWidth = mBackgroundImg->getWidth();
    }
    else
    {
        mBoxHeight = 1;
        mBoxWidth = 1;
    }
    mForegroundColor = getThemeColor(Theme::TEXT);
}
Esempio n. 17
0
ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
                         const int width, const int height,
                         const int color):
    gcn::Widget(),
    Widget2(widget),
    gcn::WidgetListener(),
    mSkin(nullptr),
    mProgress(progress),
    mProgressToGo(progress),
    mSmoothProgress(true),
    mProgressPalette(color),
    mColor(Theme::getProgressColor(color >= 0 ? color : 0, mProgress)),
    mColorToGo(mColor),
    mSmoothColorChange(true),
    mText(),
    mVertexes(new ImageCollection),
    mRedraw(true),
    mPadding(2),
    mFillPadding(3),
    mOutlineColor(getThemeColor(Theme::OUTLINE))
{
    // The progress value is directly set at load time:
    if (mProgress > 1.0f || mProgress < 0.0f)
        mProgress = 1.0f;

    mForegroundColor = getThemeColor(Theme::PROGRESS_BAR);
    addWidgetListener(this);
    setSize(width, height);

    if (Theme::instance())
    {
        mSkin = Theme::instance()->load("progressbar.xml", "");
        setPadding(mSkin->getPadding());
        mFillPadding = mSkin->getOption("fillPadding");
        setHeight(2 * mPadding + getFont()->getHeight() + 2);
    }

    mInstances++;
}
Esempio n. 18
0
void SpeechBubble::setText(const std::string &text, const bool showName)
{
    if (text == mText && (mCaption->getWidth() <= mSpeechBox->getWidth()))
        return;

    mSpeechBox->setForegroundColorAll(getThemeColor(ThemeColorId::BUBBLE_TEXT),
        getThemeColor(ThemeColorId::BUBBLE_TEXT_OUTLINE));

    int width = mCaption->getWidth();
    mSpeechBox->clearRows();
    mSpeechBox->addRow(text);
    mSpeechBox->setWidth(mSpeechBox->getDataWidth());

    const int speechWidth = mSpeechBox->getWidth();
    const int nameHeight = showName ? mCaption->getHeight() + mSpacing : 0;

    if (width < speechWidth)
        width = speechWidth;

    setContentSize(width, getFont()->getHeight() + nameHeight);
    mCaption->setPosition(0, 0);
    mSpeechBox->setPosition(0, nameHeight);
}
Esempio n. 19
0
AvatarListBox::AvatarListBox(const Widget2 *const widget,
                             AvatarListModel *const model) :
    ListBox(widget, model, "avatarlistbox.xml"),
    mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
    mShowGender(config.getBoolValue("showgender")),
    mShowLevel(config.getBoolValue("showlevel"))
{
    instances++;

    if (instances == 1)
    {
        onlineIcon = Theme::getImageFromThemeXml("circle-on.xml", "");
        offlineIcon = Theme::getImageFromThemeXml("circle-off.xml", "");
    }

    setWidth(200);

    config.addListener("showgender", this);
    config.addListener("showlevel", this);

    mForegroundColor = getThemeColor(ThemeColorId::TEXT);
    mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
}
Esempio n. 20
0
Desktop::Desktop(const Widget2 *const widget) :
    Container(widget),
    LinkHandler(),
    WidgetListener(),
    mWallpaper(nullptr),
    mVersionLabel(new BrowserBox(this, BrowserBox::AUTO_WRAP, false,
        "browserbox.xml")),
    mSkin(nullptr),
    mBackgroundColor(getThemeColor(ThemeColorId::BACKGROUND, 128)),
    mBackgroundGrayColor(getThemeColor(ThemeColorId::BACKGROUND_GRAY)),
    mShowBackground(true)
{
    addWidgetListener(this);

    Wallpaper::loadWallpapers();

    if (theme)
        mSkin = theme->load("desktop.xml", "");

    if (mSkin)
        mShowBackground = mSkin->getOption("showBackground");

    const std::string appName = branding.getValue("appName", std::string());
    if (appName.empty())
    {
        mVersionLabel->addRow(FULL_VERSION);
    }
    else
    {
        mVersionLabel->addRow(strprintf("%s (%s)", FULL_VERSION,
            appName.c_str()));
    }
    mVersionLabel->addRow("copyright",
        "(C) ManaPlus developers, http://manaplus.org");
    mVersionLabel->setLinkHandler(this);
}
Esempio n. 21
0
PartyTab::PartyTab(const Widget2 *const widget) :
    // TRANSLATORS: party chat tab name
    ChatTab(widget, _("Party"), "")
{
    setTabColor(&getThemeColor(Theme::PARTY_CHAT_TAB),
        &getThemeColor(Theme::PARTY_CHAT_TAB_OUTLINE));
    setHighlightedTabColor(&getThemeColor(Theme::PARTY_CHAT_TAB_HIGHLIGHTED),
        &getThemeColor(Theme::PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE));
    setSelectedTabColor(&getThemeColor(Theme::PARTY_CHAT_TAB_SELECTED),
        &getThemeColor(Theme::PARTY_CHAT_TAB_SELECTED_OUTLINE));
}
Esempio n. 22
0
GuildChatTab::GuildChatTab(const Widget2 *const widget) :
    // TRANSLATORS: guild chat tab name
    ChatTab(widget, _("Guild"), "")
{
    setTabColor(&getThemeColor(Theme::GUILD_CHAT_TAB),
        &getThemeColor(Theme::GUILD_CHAT_TAB_OUTLINE));
    setHighlightedTabColor(&getThemeColor(Theme::GUILD_CHAT_TAB_HIGHLIGHTED),
        &getThemeColor(Theme::GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE));
    setSelectedTabColor(&getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED),
        &getThemeColor(Theme::GUILD_CHAT_TAB_SELECTED_OUTLINE));
    mShowOnline = config.getBoolValue("showGuildOnline");
    config.addListener("showGuildOnline", this);
}
Esempio n. 23
0
Button::Button(const Widget2 *const widget) :
    Widget(widget),
    MouseListener(),
    KeyListener(),
    FocusListener(),
    WidgetListener(),
    mCaption(),
    mDescription(),
    mTextChunk(),
    mVertexes2(new ImageCollection),
    mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
    mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
    mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
    mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
    mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
    mHighlightedColor2(getThemeColor(
        ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
    mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
    mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
    mImages(nullptr),
    mImageSet(nullptr),
    mAlignment(Graphics::CENTER),
    mClickCount(0),
    mSpacing(),
    mTag(0),
    mMode(0),
    mXOffset(0),
    mYOffset(0),
    mImageWidth(0),
    mImageHeight(0),
    mHasMouse(false),
    mKeyPressed(false),
    mMousePressed(false),
    mStick(false),
    mPressed(false),
    mTextChanged(true)
{
    init();
    adjustSize();
}
Esempio n. 24
0
void ItemShortcutContainer::setSkin(const Widget2 *const widget,
                                    Skin *const skin)
{
    ShortcutContainer::setSkin(widget, skin);
    mEquipedColor = getThemeColor(ThemeColorId::ITEM_EQUIPPED, 255U);
    mEquipedColor2 = getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE, 255U);
    mUnEquipedColor = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED, 255U);
    mUnEquipedColor2 = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE,
        255U);
    mForegroundColor = getThemeColor(ThemeColorId::TEXT, 255U);
    mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE, 255U);
    if (mSkin != nullptr)
    {
        mKeyOffsetX = mSkin->getOption("keyOffsetX", 2);
        mKeyOffsetY = mSkin->getOption("keyOffsetY", 2);
    }
}
Esempio n. 25
0
TextBox::TextBox(const Widget2 *const widget) :
    Widget(widget),
    MouseListener(),
    KeyListener(),
    mTextRows(),
    mCaretColumn(0),
    mCaretRow(0),
    mMinWidth(getWidth()),
    mEditable(true),
    mOpaque(true)
{
    mAllowLogic = false;
    setText("");
    setFocusable(true);

    addMouseListener(this);
    addKeyListener(this);
    adjustSize();

    mForegroundColor = getThemeColor(Theme::TEXTBOX);
    setOpaque(false);
    setFrameSize(0);
}
Esempio n. 26
0
TextPopup::TextPopup():
    Popup("TextPopup", "textpopup.xml"),
    mText1(new Label(this)),
    mText2(new Label(this)),
    mText3(new Label(this))
{
    const int fontHeight = getFont()->getHeight();

    mText1->setPosition(0, 0);
    mText2->setPosition(0, fontHeight);
    mText3->setPosition(0, 2 * fontHeight);
    mText1->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mText2->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mText3->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));

    add(mText1);
    add(mText2);
    add(mText3);
    addMouseListener(this);
}
Esempio n. 27
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);
}
Esempio n. 28
0
    mCaption(),
    mPadding(0),
    mImagePadding(0),
    mImageSize(9),
    mSpacing(2),
    mHasMouse(false),
    mDrawBox(true)
{
    setCaption(caption);
    mAllowLogic = false;

    setFocusable(true);
    addMouseListener(this);
    addKeyListener(this);

    mForegroundColor2 = getThemeColor(Theme::CHECKBOX_OUTLINE);
    if (instances == 0)
    {
        if (theme)
        {
            mSkin = theme->load("checkbox.xml", "");
            updateAlpha();
        }
    }

    instances++;

    if (!eventId.empty())
        setActionEventId(eventId);

    if (listener)
Esempio n. 29
0
void BeingPopup::show(const int x, const int y, Being *const b)
{
    if (!b)
    {
        setVisible(false);
        return;
    }

    Label *label1 = mBeingParty;
    Label *label2 = mBeingGuild;
    Label *label3 = mBeingRank;
    Label *label4 = mBeingBuyBoard;
    Label *label5 = mBeingSellBoard;
    Label *label6 = mBeingComment;
    Label *label7 = mBeingRoom;

    b->updateComment();

    if (b->getType() == ActorType::Npc && b->getComment().empty())
    {
        setVisible(false);
        return;
    }

    mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace());
    if (gui)
    {
        if (player_relations.isGoodName(b))
            mBeingName->setFont(boldFont);
        else
            mBeingName->setFont(gui->getSecureFont());
    }
    if (b->isAdvanced())
    {
        mBeingName->setForegroundColorAll(getThemeColor(
            Theme::PLAYER_ADVANCED), getThemeColor(
            Theme::PLAYER_ADVANCED_OUTLINE));
    }
    else
    {
        mBeingName->setForegroundColorAll(getThemeColor(Theme::POPUP),
            getThemeColor(Theme::POPUP_OUTLINE));
    }

    mBeingName->adjustSize();
    label1->setCaption("");
    label2->setCaption("");
    label3->setCaption("");
    label4->setCaption("");
    label5->setCaption("");
    label6->setCaption("");
    label7->setCaption("");

#ifdef EATHENA_SUPPORT
    const ActorType::Type type = b->getType();
    if (type == ActorType::Pet)
    {
        PetInfo *const info = PlayerInfo::getPet();
        if (info)
        {
            // TRANSLATORS: being popup label
            label1->setCaption(strprintf(_("Hungry: %d"),
                info->hungry));
            label1->adjustSize();
            // TRANSLATORS: being popup label
            label2->setCaption(strprintf(_("Intimacy: %d"),
                info->intimacy));
            label2->adjustSize();
            label3 = nullptr;
            label4 = nullptr;
            label5 = nullptr;
            label6 = nullptr;
            label7 = nullptr;
        }
    }
    else if (type == ActorType::Homunculus)
    {
        HomunculusInfo *const info = PlayerInfo::getHomunculus();
        if (info)
        {
            // TRANSLATORS: being popup label
            label1->setCaption(strprintf(_("Hungry: %d"),
                info->hungry));
            label1->adjustSize();
            // TRANSLATORS: being popup label
            label2->setCaption(strprintf(_("Intimacy: %d"),
                info->intimacy));
            label2->adjustSize();
            label3 = nullptr;
            label4 = nullptr;
            label5 = nullptr;
            label6 = nullptr;
            label7 = nullptr;
        }
    }
    else
#endif
    {
        if (!(b->getPartyName().empty()))
        {
            // TRANSLATORS: being popup label
            label1->setCaption(strprintf(_("Party: %s"),
                b->getPartyName().c_str()));
            label1->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = label5;
            label5 = label4;
            label4 = label3;
            label3 = label2;
            label2 = label1;
            label1 = nullptr;
        }

        if (!(b->getGuildName().empty()))
        {
            // TRANSLATORS: being popup label
            label2->setCaption(strprintf(_("Guild: %s"),
                b->getGuildName().c_str()));
            label2->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = label5;
            label5 = label4;
            label4 = label3;
            label3 = label2;
            label2 = nullptr;
        }

        if (b->getPvpRank() > 0)
        {
            // TRANSLATORS: being popup label
            label3->setCaption(strprintf(_("Pvp rank: %u"),
                b->getPvpRank()));
            label3->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = label5;
            label5 = label4;
            label4 = label3;
            label3 = nullptr;
        }

        if (!b->getBuyBoard().empty())
        {
            // TRANSLATORS: being popup label
            label4->setCaption(strprintf(_("Buy shop: %s"),
                b->getBuyBoard().c_str()));
            label4->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = label5;
            label5 = label4;
            label4 = nullptr;
        }

        if (!b->getSellBoard().empty())
        {
            // TRANSLATORS: being popup label
            label5->setCaption(strprintf(_("Sell shop: %s"),
                b->getSellBoard().c_str()));
            label5->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = label5;
            label5 = nullptr;
        }

        if (!b->getComment().empty())
        {
            // TRANSLATORS: being popup label
            label6->setCaption(strprintf(_("Comment: %s"),
                b->getComment().c_str()));
            label6->adjustSize();
        }
        else
        {
            label7 = label6;
            label6 = nullptr;
        }
#ifdef EATHENA_SUPPORT
        const ChatObject *const chat = b->getChat();
        if (chat)
        {
            // TRANSLATORS: being popup label
            label7->setCaption(strprintf(_("Chat room: %s"),
                chat->title.c_str()));
            label7->adjustSize();
        }
        else
        {
            label7 = nullptr;
        }
#endif
    }

    int minWidth = mBeingName->getWidth();
    if (label1 && label1->getWidth() > minWidth)
        minWidth = label1->getWidth();
    if (label2 && label2->getWidth() > minWidth)
        minWidth = label2->getWidth();
    if (label3 && label3->getWidth() > minWidth)
        minWidth = label3->getWidth();
    if (label4 && label4->getWidth() > minWidth)
        minWidth = label4->getWidth();
    if (label5 && label5->getWidth() > minWidth)
        minWidth = label5->getWidth();
    if (label6 && label6->getWidth() > minWidth)
        minWidth = label6->getWidth();
    if (label7 && label7->getWidth() > minWidth)
        minWidth = label7->getWidth();

    const int height1 = getFont()->getHeight();
    int height = height1;
    if (label1)
        height += height1;
    if (label2)
        height += height1;
    if (label3)
        height += height1;
    if (label4)
        height += height1;
    if (label5)
        height += height1;
    if (label6)
        height += height1;
    if (label7)
        height += height1;

    setContentSize(minWidth, height);
    position(x, y);
    return;
}
Esempio n. 30
0
BeingPopup::BeingPopup() :
    Popup("BeingPopup", "beingpopup.xml"),
    mBeingName(new Label(this, "A")),
    mBeingParty(new Label(this, "A")),
    mBeingGuild(new Label(this, "A")),
    mBeingRank(new Label(this, "A")),
    mBeingComment(new Label(this, "A")),
    mBeingBuyBoard(new Label(this, "A")),
    mBeingSellBoard(new Label(this, "A")),
    mBeingRoom(new Label(this, "A"))
{
    // Being Name
    mBeingName->setFont(boldFont);
    mBeingName->setPosition(0, 0);

    const int fontHeight = mBeingName->getHeight();
    setMinHeight(fontHeight);

    // Being's party
    mBeingParty->setPosition(0, fontHeight);
    // Being's party
    mBeingGuild->setPosition(0, 2 * fontHeight);
    mBeingRank->setPosition(0, 3 * fontHeight);
    mBeingBuyBoard->setPosition(0, 4 * fontHeight);
    mBeingSellBoard->setPosition(0, 4 * fontHeight);
    mBeingComment->setPosition(0, 5 * fontHeight);
    mBeingRoom->setPosition(0, 6 * fontHeight);

    mBeingParty->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingGuild->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingRank->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingBuyBoard->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingSellBoard->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingComment->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
    mBeingRoom->setForegroundColorAll(getThemeColor(Theme::POPUP),
        getThemeColor(Theme::POPUP_OUTLINE));
}