rework networking indicator dot

This commit is contained in:
2025-04-20 07:33:34 +01:00
parent 6079a72f47
commit d789b0f62d
5 changed files with 31 additions and 30 deletions
+1 -14
View File
@@ -1,7 +1,4 @@
use crate::util::consts::{
colours,
game::{EXE_ENHANCED, EXE_LEGACY},
};
use crate::util::consts::game::{EXE_ENHANCED, EXE_LEGACY};
use std::{
path::Path,
time::{Duration, Instant},
@@ -44,16 +41,6 @@ impl From<bool> for BlockedStatus {
}
}
impl From<BlockedStatus> for eframe::egui::Color32 {
fn from(value: BlockedStatus) -> Self {
match value {
BlockedStatus::Blocked => colours::RED,
BlockedStatus::Failed => colours::YELLOW,
BlockedStatus::Unblocked => colours::GREEN,
}
}
}
impl BlockedStatus {
pub fn to_color32(self) -> eframe::egui::Color32 {
self.into()
+12 -8
View File
@@ -139,9 +139,20 @@ impl App {
.outer_margin(egui::vec2(0.0, -2.0))
.show(ui, |ui| {
let response = ui.add_enabled_ui(self.flags.elevated, |ui| {
let label = ui.horizontal(|ui| {
let label = ui.label("Game's network access");
ui.add_space(1.0);
ui.add(
egui::Image::new(egui::include_image!("../../assets/circle.svg"))
.max_size([4.0, 4.0].into())
.tint(self.game_networking.blocked_status.to_color32()),
)
.on_hover_text("This turns yellow if GTA Tools\ncannot find your game.");
self.game_networking.if_failed_return_to_unblocked();
label
});
ui.horizontal(|ui| {
let available_width = label.rect.width();
let available_width = label.inner.rect.width();
let spacing = ui.spacing().item_spacing.x;
let button_width = (available_width - spacing) / 2.0;
if ui
@@ -156,13 +167,6 @@ impl App {
{
self.game_networking.unblock_all();
}
ui.add(
egui::Image::new(egui::include_image!("../../assets/circle.svg"))
.max_size([4.0, 4.0].into())
.tint(self.game_networking.blocked_status.to_color32()),
)
.on_hover_text("This turns yellow if GTA Tools\ncannot find your game.");
self.game_networking.if_failed_return_to_unblocked();
});
});
response.response.on_disabled_hover_text(
+16
View File
@@ -0,0 +1,16 @@
use crate::features::game_networking::BlockedStatus;
use eframe::egui;
pub const RED: egui::Color32 = egui::Color32::from_rgb(255, 128, 128);
pub const YELLOW: egui::Color32 = egui::Color32::from_rgb(255, 255, 128);
pub const GREEN: egui::Color32 = egui::Color32::from_rgb(128, 255, 128);
impl From<BlockedStatus> for egui::Color32 {
fn from(value: BlockedStatus) -> Self {
match value {
BlockedStatus::Blocked => RED,
BlockedStatus::Failed => YELLOW,
BlockedStatus::Unblocked => GREEN,
}
}
}
+1
View File
@@ -1,4 +1,5 @@
mod app;
mod colours;
mod debug;
pub mod run;
pub mod settings;
-7
View File
@@ -8,10 +8,3 @@ pub mod game {
pub const EXE_LEGACY: &str = "GTA5.exe";
pub const WINDOW_TITLE: &str = "Grand Theft Auto V";
}
pub mod colours {
use eframe::egui::Color32;
pub const RED: Color32 = Color32::from_rgb(249, 101, 84);
pub const YELLOW: Color32 = Color32::from_rgb(249, 236, 84);
pub const GREEN: Color32 = Color32::from_rgb(104, 249, 84);
}