代码拉取完成,页面将自动刷新
#include "shopscene.h"
#include "ui_shopscene.h"
#include "config.h"
#include <QPainter>
ShopScene::ShopScene(QWidget *parent) :
QDialog(parent),
ui(new Ui::ShopScene)
{
ui->setupUi(this);
// 设置窗口尺寸
this->setFixedSize(WidgetInfo::WIDGET_WIDTH, WidgetInfo::WIDGET_HEIGHT);
// 设置窗口图标
this->setWindowIcon(QIcon(GAME_ICON));
// 设置窗口名字
this->setWindowTitle(GAME_TITLE);
setMouseTracking(true);
int ButtonSize = (WidgetInfo::WIDGET_WIDTH - 5 * 100) / 4;
ui->bigger_hub->setFixedSize(ButtonSize, ButtonSize);
ui->clear_barriers->setFixedSize(ButtonSize, ButtonSize);
ui->increase_mine->setFixedSize(ButtonSize, ButtonSize);
ui->increase_item_value->setFixedSize(ButtonSize, ButtonSize);
}
ShopScene::~ShopScene()
{
delete ui;
}
void ShopScene::paintEvent(QPaintEvent *e)
{
int ButtonSize = (WidgetInfo::WIDGET_WIDTH - 5 * 100) / 4;
QPainter painter(this);
painter.setFont(QFont("楷体", 25, QFont::Bold));
// 更大的hub
painter.drawText(100 * 1 + ButtonSize * 0 + 14, WidgetInfo::WIDGET_HEIGHT / 2 - 120, QString("更大的hub"));
ui->bigger_hub->move(100 * 1 + ButtonSize * 0, WidgetInfo::WIDGET_HEIGHT / 2 - 100);
painter.drawText(100 * 1 + ButtonSize * 0 + 27, WidgetInfo::WIDGET_HEIGHT / 2 + 100, QString("¥ ") + QString::number(StoreMenoey::BIGGER_HUB));
// 清空障碍
painter.drawText(100 * 2 + ButtonSize * 1 + 14, WidgetInfo::WIDGET_HEIGHT / 2 - 120, QString("清空障碍"));
ui->clear_barriers->move(100 * 2 + ButtonSize * 1, WidgetInfo::WIDGET_HEIGHT / 2 - 100);
painter.drawText(100 * 2 + ButtonSize * 1 + 27, WidgetInfo::WIDGET_HEIGHT / 2 + 100, QString("¥ ") + QString::number(StoreMenoey::CLEAR_BARRIERS));
// 增加矿地
painter.drawText(100 * 3 + ButtonSize * 2 + 14, WidgetInfo::WIDGET_HEIGHT / 2 - 120, QString("增加矿地"));
ui->increase_mine->move(100 * 3 + ButtonSize * 2, WidgetInfo::WIDGET_HEIGHT / 2 - 100);
painter.drawText(100 * 3 + ButtonSize * 2 + 27, WidgetInfo::WIDGET_HEIGHT / 2 + 100, QString("¥ ") + QString::number(StoreMenoey::INCREASE_MINE));
// 升级item
painter.drawText(100 * 4 + ButtonSize * 3 + 14, WidgetInfo::WIDGET_HEIGHT / 2 - 120, QString("升级item"));
ui->increase_item_value->move(100 * 4 + ButtonSize * 3, WidgetInfo::WIDGET_HEIGHT / 2 - 100);
painter.drawText(100 * 4 + ButtonSize * 3 + 27, WidgetInfo::WIDGET_HEIGHT / 2 + 100, QString("¥ ") + QString::number(StoreMenoey::INCREASE_ITEM_VALUE));
// 返回游戏
painter.drawText(WidgetInfo::WIDGET_WIDTH - 155, WidgetInfo::WIDGET_HEIGHT - 165, QString("离开商店"));
ui->return_button->move(WidgetInfo::WIDGET_WIDTH - 150, WidgetInfo::WIDGET_HEIGHT - 150);
}
void ShopScene::on_bigger_hub_clicked()
{
emit bigger();
}
void ShopScene::on_clear_barriers_clicked()
{
emit clear();
}
void ShopScene::on_increase_mine_clicked()
{
emit increaseMine();
}
void ShopScene::on_increase_item_value_clicked()
{
emit increaseItemValue();
}
void ShopScene::on_return_button_clicked()
{
reject();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。