more work on the courtroom + added the aocharbutton class
This commit is contained in:
parent
0002a02421
commit
c4dff0f528
@ -28,7 +28,8 @@ SOURCES += main.cpp\
|
||||
packet_distribution.cpp \
|
||||
hex_functions.cpp \
|
||||
encryption_functions.cpp \
|
||||
courtroom.cpp
|
||||
courtroom.cpp \
|
||||
aocharbutton.cpp
|
||||
|
||||
HEADERS += lobby.h \
|
||||
text_file_functions.h \
|
||||
@ -44,4 +45,5 @@ HEADERS += lobby.h \
|
||||
aopacket.h \
|
||||
hex_functions.h \
|
||||
encryption_functions.h \
|
||||
courtroom.h
|
||||
courtroom.h \
|
||||
aocharbutton.h
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "lobby.h"
|
||||
#include "courtroom.h"
|
||||
#include "networkmanager.h"
|
||||
|
||||
#include "aoapplication.h"
|
||||
@ -47,8 +48,7 @@ void AOApplication::construct_courtroom()
|
||||
return;
|
||||
}
|
||||
|
||||
//T0D0, make custom Courtroom class and uncomment
|
||||
//w_courtroom = new QMainWindow(this);
|
||||
w_courtroom = new Courtroom(this);
|
||||
courtroom_constructed = true;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,7 @@ public:
|
||||
|
||||
NetworkManager *net_manager;
|
||||
Lobby *w_lobby;
|
||||
//T0D0: change to custom class "Courtroom"
|
||||
QMainWindow *w_courtroom;
|
||||
Courtroom *w_courtroom;
|
||||
|
||||
bool lobby_constructed = false;
|
||||
bool courtroom_constructed = false;
|
||||
|
33
aocharbutton.cpp
Normal file
33
aocharbutton.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "aocharbutton.h"
|
||||
|
||||
#include "path_functions.h"
|
||||
#include "file_functions.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
AOCharButton::AOCharButton(QWidget *parent)
|
||||
{
|
||||
m_parent = parent;
|
||||
|
||||
this->resize(60, 60);
|
||||
}
|
||||
|
||||
void AOCharButton::set_image(QString p_character)
|
||||
{
|
||||
QString image_path = get_character_path(p_character) + "char_icon.png";
|
||||
QString legacy_path = get_demothings_path() + p_character.toLower() + "_char_icon.png";
|
||||
|
||||
if (file_exists(image_path))
|
||||
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
|
||||
else if (file_exists(legacy_path))
|
||||
{
|
||||
this->setStyleSheet("border-image:url(\"" + legacy_path + "\")");
|
||||
//ninja optimization
|
||||
QFile::copy(legacy_path, image_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setStyleSheet("border-image:url()");
|
||||
this->setText(p_character);
|
||||
}
|
||||
}
|
21
aocharbutton.h
Normal file
21
aocharbutton.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef AOCHARBUTTON_H
|
||||
#define AOCHARBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class AOCharButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AOCharButton(QWidget *parent);
|
||||
|
||||
void set_image(QString p_character);
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
#endif // AOCHARBUTTON_H
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "aoapplication.h"
|
||||
|
||||
Courtroom::Courtroom(AOApplication *parent) : QMainWindow(parent)
|
||||
Courtroom::Courtroom(AOApplication *parent) : QMainWindow()
|
||||
{
|
||||
ao_app = parent;
|
||||
|
||||
|
13
courtroom.h
13
courtroom.h
@ -3,6 +3,7 @@
|
||||
|
||||
#include "aoimage.h"
|
||||
#include "aobutton.h"
|
||||
#include "aobuttongrid.h"
|
||||
#include "aopacket.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
@ -84,17 +85,15 @@ private:
|
||||
|
||||
QComboBox *ui_text_color;
|
||||
|
||||
QSlider *ui_music_slider;
|
||||
QSlider *ui_sfx_slider;
|
||||
QSlider *ui_blip_slider;
|
||||
|
||||
|
||||
AOImage *ui_muted;
|
||||
|
||||
|
||||
|
||||
//ui_charselect w/ icons
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
AOImage *ui_char_select_background;
|
||||
AOButtonGrid *char_button_grid;
|
||||
};
|
||||
|
||||
#endif // COURTROOM_H
|
||||
|
@ -19,3 +19,13 @@ QString get_default_theme_path()
|
||||
{
|
||||
return get_base_path() + "themes/default/";
|
||||
}
|
||||
|
||||
QString get_character_path(QString p_character)
|
||||
{
|
||||
return get_base_path() + "characters/" + p_character.toLower() + "/";
|
||||
}
|
||||
|
||||
QString get_demothings_path()
|
||||
{
|
||||
return get_base_path() + "misc/demothings/";
|
||||
}
|
||||
|
@ -6,5 +6,7 @@
|
||||
QString get_base_path();
|
||||
QString get_theme_path();
|
||||
QString get_default_theme_path();
|
||||
QString get_character_path(QString p_character);
|
||||
QString get_demothings_path();
|
||||
|
||||
#endif // PATH_FUNCTIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user