Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Attorney_Online.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ QMAKE_CXXFLAGS += "-fno-sized-deallocation"
# Uncomment for verbose animation logging
# DEFINES += DEBUG_MOVIE

# Uncomment for slide animation debug features
# DEFINES += DEBUG_TRANSITION

# Uncomment for building with debug symbols
# CONFIG += debug

Expand Down
9 changes: 8 additions & 1 deletion include/aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AOApplication : public QApplication {
QString get_asset(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="");
QString get_image(QString p_element, QString p_theme="", QString p_subtheme="", QString p_default_theme="", QString p_misc="", QString p_character="", QString p_placeholder="", bool static_image=false);
QString get_sfx(QString p_sfx, QString p_misc="", QString p_character="");
QString get_pos_path(const QString& pos, bool desk = false);
QPair<QString, int> get_pos_path(const QString &pos, bool desk = false);
QString get_case_sensitive_path(QString p_file);
QString get_real_path(const VPath &vpath, const QStringList &suffixes={""});
void invalidate_lookup_cache();
Expand Down Expand Up @@ -279,6 +279,13 @@ class AOApplication : public QApplication {
// Returns whether the given pos is a judge position
bool get_pos_is_judge(const QString &p_pos);

/**
* @brief Returns the duration of the transition animation between the two
* given positions, if it exists
*/
int get_pos_transition_duration(const QString &old_pos,
const QString &new_pos);

// Returns the total amount of emotes of p_char
int get_emote_number(QString p_char);

Expand Down
50 changes: 40 additions & 10 deletions include/aolayer.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#ifndef AOLAYER_H
#define AOLAYER_H

#include <QBitmap>
#include <QDebug>
#include <QElapsedTimer>
#include <QImageReader>
#include <QLabel>
#include <QTimer>
#include <QBitmap>
#include <QtConcurrent/QtConcurrentRun>
#include <QMutex>
#include <QPropertyAnimation>
#include <QTimer>
#include <QWaitCondition>
#include <QtConcurrent/QtConcurrentRun>

class AOApplication;
class VPath;
Expand Down Expand Up @@ -84,17 +85,36 @@ class AOLayer : public QLabel {
// Move the label and center it
void move_and_center(int ax, int ay);

// Returns the scaling factor
float get_scaling_factor();

// This is somewhat pointless now as there's no "QMovie" object to resize, aka
// no "combo" to speak of
void combo_resize(int w, int h);

// Return the frame delay adjusted for speed
int get_frame_delay(int delay);

/**
* @brief Returns the x offset to use to ensure proper centering in the
* viewport. This is used by courtroom transition code to know exactly where
* to put the characters at the start and end of the animation.
* @return The offset to center the pixmap in the viewport
*/
int get_centered_offset();

// iterate through a list of paths and return the first entry that exists. if
// none exist, return NULL (safe because we check again for existence later)
QString find_image(QStringList p_list);

QPropertyAnimation *slide(int newcenter, int duration);

// Start playback of the movie (if animated).
void play();

// Freeze the movie at the current frame.
void freeze();

protected:
AOApplication *ao_app;
QVector<QPixmap> movie_frames;
Expand All @@ -117,6 +137,8 @@ class AOLayer : public QLabel {
int f_w = 0;
int f_h = 0;

float scaling_factor = 0.0;

int frame = 0;
int max_frames = 0;
int last_max_frames = 0;
Expand All @@ -127,21 +149,29 @@ class AOLayer : public QLabel {

int duration = 0;

// Start playback of the movie (if animated).
void play();

// Freeze the movie at the current frame.
void freeze();

// Retreive a pixmap adjused for mirroring/aspect ratio shenanigans from a
// provided QImage
QPixmap get_pixmap(QImage image);

// Set the movie's frame to provided pixmap
void set_frame(QPixmap f_pixmap);

// If set to anything other than -1, overrides center_pixmap to use it as a
// pixel position to center at. Currently only used by background layers
int g_center = -1;
int last_center = -1; // g_center from the last image.
int centered_offset = 0;

// Center the QLabel in the viewport based on the dimensions of f_pixmap
void center_pixmap(QPixmap f_pixmap);

/*!
@brief Get the position to move us to, given the pixel X position of the
point in the original image that we'd like to be centered.
@return The position to move to.
*/
int get_pos_from_center(int f_center);

private:
// Populates the frame and delay vectors.
void populate_vectors();
Expand All @@ -167,7 +197,7 @@ class BackgroundLayer : public AOLayer {
Q_OBJECT
public:
BackgroundLayer(QWidget *p_parent, AOApplication *p_ao_app);
void load_image(QString p_filename);
void load_image(QString p_filename, int center = -1);
};

class CharLayer : public AOLayer {
Expand Down
37 changes: 31 additions & 6 deletions include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ class Courtroom : public QMainWindow {
// sets desk and bg based on pos in chatmessage
void set_scene(bool show_desk, QString f_side);

// sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5
void set_self_offset(const QString& p_list);
// sets p_layer according to SELF_OFFSET, only a function bc it's used with
// desk_mod 4 and 5
void set_self_offset(const QString &p_list, AOLayer *p_layer);

// takes in serverD-formatted IP list as prints a converted version to server
// OOC admittedly poorly named
Expand Down Expand Up @@ -267,6 +268,9 @@ class Courtroom : public QMainWindow {
// Handle the stuff that comes when the character appears on screen and starts animating (preanims etc.)
void handle_ic_message();

// Start the logic for doing a courtroom pan slide
void do_transition(QString desk_mod, QString old_pos, QString new_pos);

// Display the character.
void display_character();

Expand Down Expand Up @@ -368,6 +372,9 @@ class Courtroom : public QMainWindow {
QParallelAnimationGroup *screenshake_animation_group =
new QParallelAnimationGroup;

QParallelAnimationGroup *transition_animation_group =
new QParallelAnimationGroup;

bool next_character_is_not_special = false; // If true, write the
// next character as it is.

Expand Down Expand Up @@ -496,9 +503,15 @@ class Courtroom : public QMainWindow {

// Minumum and maximum number of parameters in the MS packet
static const int MS_MINIMUM = 15;
static const int MS_MAXIMUM = 31;
static const int MS_MAXIMUM = 32;
QString m_chatmessage[MS_MAXIMUM];

/**
* @brief The amount of time to wait at the start and end of slide
* animations
*/
static const int TRANSITION_BOOKEND_DELAY = 300;

QString previous_ic_message = "";
QString additive_previous = "";

Expand Down Expand Up @@ -629,6 +642,11 @@ class Courtroom : public QMainWindow {
QString current_background = "default";
QString current_side = "";

// used for courtroom slide logic
QString last_side = "";
int last_offset = 0;
int last_v_offset = 0;

QString last_music_search = "";
QString last_area_search = "";

Expand All @@ -654,6 +672,8 @@ class Courtroom : public QMainWindow {
SplashLayer *ui_vp_speedlines;
CharLayer *ui_vp_player_char;
CharLayer *ui_vp_sideplayer_char;
CharLayer *ui_vp_dummy_char;
CharLayer *ui_vp_sidedummy_char;
BackgroundLayer *ui_vp_desk;
AOEvidenceDisplay *ui_vp_evidence_display;
AOImage *ui_vp_chatbox;
Expand Down Expand Up @@ -752,6 +772,8 @@ class Courtroom : public QMainWindow {
QCheckBox *ui_immediate;
QCheckBox *ui_showname_enable;

QCheckBox *ui_slide_enable;

AOButton *ui_custom_objection;
QMenu *custom_obj_menu;
AOButton *ui_realization;
Expand Down Expand Up @@ -844,6 +866,7 @@ public slots:
void objection_done();
void preanim_done();
void do_screenshake();
void on_transition_finish();
void do_flash();
void do_effect(QString fx_path, QString fx_sound, QString p_char,
QString p_folder);
Expand Down Expand Up @@ -973,10 +996,8 @@ private slots:
void on_call_mod_clicked();
void on_settings_clicked();

void on_pre_clicked();
void on_flip_clicked();
void focus_ic_input();
void on_additive_clicked();
void on_guard_clicked();

void on_showname_enable_clicked();

Expand Down Expand Up @@ -1021,6 +1042,10 @@ private slots:

void preview_emote(QString emote);
void update_emote_preview();

// After attempting to play a transition animation, clean up the viewport
// objects for everyone else and continue the IC processing callstack
void post_transition_cleanup();
};

#endif // COURTROOM_H
1 change: 1 addition & 0 deletions include/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ enum CHAT_MESSAGE {
ADDITIVE,
EFFECTS,
BLIPNAME,
SLIDE,
};

enum EMOTE_MOD_TYPE {
Expand Down
5 changes: 5 additions & 0 deletions include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class Options {
bool networkedFrameSfxEnabled() const;
void setNetworkedFrameSfxEnabled(bool value);

// Returns the value of whether courtroom slide animations should be played
// on this client.
bool slidesEnabled() const;
void setSlidesEnabled(bool value);

// Returns the value of whether colored ic log should be a thing.
// from the config.ini.
bool colorLogEnabled() const;
Expand Down
1 change: 1 addition & 0 deletions include/widgets/aooptionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AOOptionsDialog : public QDialog {
QPushButton *ui_theme_reload_button;
QPushButton *ui_theme_folder_button;
QCheckBox *ui_evidence_double_click_cb;
QCheckBox *ui_slides_cb;
QCheckBox *ui_animated_theme_cb;
QSpinBox *ui_stay_time_spinbox;
QCheckBox *ui_instant_objection_cb;
Expand Down
24 changes: 22 additions & 2 deletions resource/ui/options_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-511</y>
<width>394</width>
<height>858</height>
<height>850</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
Expand Down Expand Up @@ -556,6 +556,26 @@
</property>
</widget>
</item>
<item row="33" column="0">
<widget class="QLabel" name="slides_lbl">
<property name="toolTip">
<string>If ticked, slide animations will play when requested.</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Slide Animations:</string>
</property>
</widget>
</item>
<item row="33" column="1">
<widget class="QCheckBox" name="slides_cb">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down
Loading