1 Star 0 Fork 0

Mrack/ MyShapez

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
shopscene.cpp 3.14 KB
一键复制 编辑 原始数据 按行查看 历史
Mrack 提交于 2024-06-24 23:59 . 888
#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();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stucky/MyShapez-new.git
[email protected]:stucky/MyShapez-new.git
stucky
MyShapez-new
MyShapez
master

搜索帮助