Skip to content

Commit

Permalink
Simplify ini config format
Browse files Browse the repository at this point in the history
  • Loading branch information
in1tiate committed May 17, 2024
1 parent 3835402 commit 001da4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2765,8 +2765,10 @@ void Courtroom::do_transition(QString p_desk_mod, QString old_pos, QString new_p
QPair<QString, int> old_pos_pair = ao_app->get_pos_path(t_old_pos);
QPair<QString, int> new_pos_pair = ao_app->get_pos_path(t_new_pos);

// todo: network slide enable checkbox
if (old_pos == new_pos || old_pos_pair.first != new_pos_pair.first || new_pos_pair.second == -1 || !Options::getInstance().slidesEnabled() || m_chatmessage[SLIDE] != "1") {
int duration = ao_app->get_pos_transition_duration(t_old_pos, t_new_pos);

// conditions to stop slide
if (old_pos == new_pos || old_pos_pair.first != new_pos_pair.first || new_pos_pair.second == -1 || !Options::getInstance().slidesEnabled() || m_chatmessage[SLIDE] != "1" || duration == -1) {
#ifdef DEBUG_TRANSITION
qDebug() << "skipping transition - not applicable";
#endif
Expand All @@ -2786,8 +2788,6 @@ void Courtroom::do_transition(QString p_desk_mod, QString old_pos, QString new_p

const QList<AOLayer *> &affected_list = {ui_vp_background, ui_vp_desk, ui_vp_player_char, ui_vp_sideplayer_char};

int duration = ao_app->get_pos_transition_duration(t_old_pos, t_new_pos);

// Set up the background, desk, and player objects' animations

float scaling_factor = ui_vp_background->get_scaling_factor();
Expand Down
9 changes: 4 additions & 5 deletions src/path_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ QPair<QString, int> AOApplication::get_pos_path(const QString &pos,
QStringList f_pos_split = f_pos.split(":");
int f_center = -1;
if (f_pos_split.size() > 1) { // Subposition, get center info
bool bOk = false;
int subpos_center =
read_design_ini(f_pos_split[0] + "/" + f_pos_split[1] + "_center",
get_background_path("design.ini"))
.toInt(&bOk);
bool bOk;
int subpos_center = read_design_ini(f_pos + "/pos_center",
get_background_path("design.ini"))
.toInt(&bOk);
if (bOk) {
f_center = subpos_center;
}
Expand Down
35 changes: 14 additions & 21 deletions src/text_file_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,26 +875,19 @@ bool AOApplication::get_pos_is_judge(const QString &p_pos)
int AOApplication::get_pos_transition_duration(const QString &old_pos,
const QString &new_pos)
{
QString true_pos = old_pos.split(":")[0];
if (old_pos.split(":").size() < 2 || new_pos.split(":").size() < 2 ||
(true_pos != new_pos.split(":")[0]))
return -1;
QStringList transitions = read_design_ini(true_pos + "/transitions",
get_background_path("design.ini"))
.split(",");
for (const QString &transition : transitions) {
QStringList transition_split = transition.split(":");
if (transition_split.contains(old_pos.split(":")[1]) &&
transition_split.contains(new_pos.split(":")[1])) {
if (transition_split.size() < 3 || !transition_split[2].toInt() ||
transition_split[2].toInt() < 0) {
return -1; // invalid format
}
else
return transition_split[2].toInt();
}
else
continue;
if (old_pos.split(":").size() < 2 || new_pos.split(":").size() < 2) {
return -1; // no subpositions
}
return -1;

QString new_subpos = new_pos.split(":")[1];

bool ok;
int duration = read_design_ini(old_pos + "/slide_ms_" + new_subpos,
get_background_path("design.ini"))
.toInt(&ok);
if (ok) {
return duration;
}
else
return -1; // invalid
}

0 comments on commit 001da4b

Please sign in to comment.