Skip to content

Commit b7281e4

Browse files
committed
better requires message
1 parent 1b564da commit b7281e4

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

gui/src/app.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use egui::{Color32, Id, Label, Modal, Sense};
88

99
use log::{error, info, LevelFilter};
10-
use plox::{rules::EWarningRule, update_new_load_order, GRAPH_FILE};
10+
use plox::{rules::EWarningRule, update_new_load_order, ESupportedGame, GRAPH_FILE};
1111
use simplelog::WriteLogger;
1212

1313
use crate::{init_parser, AppData, AppSettings, ELoadStatus, PLOX_CONF_FILE, PLOX_LOG_FILE};
@@ -457,12 +457,21 @@ impl eframe::App for TemplateApp {
457457
} else {
458458
"Unknown".to_string()
459459
};
460-
ui.heading(format!(
461-
"PLOX v{} - {:?} v{:?}",
462-
crate::CARGO_PKG_VERSION,
463-
data.game,
464-
game_version
465-
));
460+
461+
if data.game == ESupportedGame::Cyberpunk {
462+
ui.heading(format!(
463+
"PLOX v{} - {:?} v{:?}",
464+
crate::CARGO_PKG_VERSION,
465+
data.game,
466+
game_version
467+
));
468+
} else {
469+
ui.heading(format!(
470+
"PLOX v{} - {:?}",
471+
crate::CARGO_PKG_VERSION,
472+
data.game
473+
));
474+
}
466475

467476
// filters
468477
ui.horizontal(|ui| {

src/rules.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum EWarningRule {
4141
/// A rule as specified in the rules document
4242
pub trait TWarningRule {
4343
/// every rule may have a comment describing why it failed
44-
fn get_comment(&self) -> &str;
44+
fn get_comment(&self) -> String;
4545
fn get_plugins(&self) -> Vec<String>;
4646

4747
fn set_comment(&mut self, comment: String);
@@ -50,7 +50,7 @@ pub trait TWarningRule {
5050
}
5151

5252
impl TWarningRule for EWarningRule {
53-
fn get_comment(&self) -> &str {
53+
fn get_comment(&self) -> String {
5454
match self {
5555
EWarningRule::Note(x) => x.get_comment(),
5656
EWarningRule::Conflict(x) => x.get_comment(),
@@ -417,8 +417,8 @@ impl Note {
417417
}
418418
}
419419
impl TWarningRule for Note {
420-
fn get_comment(&self) -> &str {
421-
self.comment.as_str()
420+
fn get_comment(&self) -> String {
421+
self.comment.clone()
422422
}
423423
fn get_plugins(&self) -> Vec<String> {
424424
self.plugins.clone()
@@ -499,8 +499,8 @@ impl Conflict {
499499
}
500500
}
501501
impl TWarningRule for Conflict {
502-
fn get_comment(&self) -> &str {
503-
self.comment.as_str()
502+
fn get_comment(&self) -> String {
503+
self.comment.clone()
504504
}
505505
fn get_plugins(&self) -> Vec<String> {
506506
self.plugins.clone()
@@ -578,8 +578,17 @@ impl Requires {
578578
}
579579
}
580580
impl TWarningRule for Requires {
581-
fn get_comment(&self) -> &str {
582-
self.comment.as_str()
581+
fn get_comment(&self) -> String {
582+
let mut comment = self.comment.clone();
583+
584+
// automatically set the comment to the two expressions
585+
if let Some(expr_a) = &self.expression_a {
586+
if let Some(expr_b) = &self.expression_b {
587+
comment = format!("'{}' requires '{}' ({})", expr_a, expr_b, self.comment);
588+
}
589+
}
590+
591+
comment
583592
}
584593
fn get_plugins(&self) -> Vec<String> {
585594
self.plugins.clone()
@@ -670,8 +679,8 @@ impl Patch {
670679
}
671680
}
672681
impl TWarningRule for Patch {
673-
fn get_comment(&self) -> &str {
674-
self.comment.as_str()
682+
fn get_comment(&self) -> String {
683+
self.comment.clone()
675684
}
676685
fn get_plugins(&self) -> Vec<String> {
677686
self.plugins.clone()

0 commit comments

Comments
 (0)