Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality of Life Improvements: Bomb Info + Misc #64

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

RemainingToast
Copy link

bomb info

I couldn't even see it before because of chat being in the way + now its draggable to any place you want.

@WolverinDEV
Copy link
Collaborator

Hey,
the bomb info should be rendered after all players in the top right corner.
This should have fixed the chat overlay issue.

I like the idea, to make the bomb info draggable, but I don't like to have it rendered as window contently.
Especially as InGui windows always have this black background. I'm not sure, how a better alternative would look like tough.

@RemainingToast
Copy link
Author

the bomb info should be rendered after all players in the top right corner.

I didn't experience that.

As for the background is it possible to change the imgui style background to a higher opacity. (I'm not really experienced in ImGui to know how)

@RemainingToast
Copy link
Author

@WolverinDEV what changes should I make?

@WolverinDEV
Copy link
Collaborator

@WolverinDEV what changes should I make?

I'm not 100 % sure if the best solution is to make the bomb info moveable or just to fix #70.
As of right now, I think it's preferable to just fix #70 :)

@RemainingToast
Copy link
Author

Alright, well personally I prefer the window- also I believe the ability it adds to move it around will fix any issues that arise from having a fixed position...

I will make my pr have more substance though and work on adding whether the bomb was dropped to the bomb info.

@RemainingToast RemainingToast changed the title Made Bomb Info ImGui Window Add More Bomb Info + ImGui Window Oct 12, 2023
@RemainingToast
Copy link
Author

Maybe some more people can give their feedback?

👍 ImGui Window preview
👎 Regular Implementation

@user-420
Copy link

moveable but transparent background and no bar at the top of it when the menu is closed would be sick

@RemainingToast
Copy link
Author

moveable but transparent background and no bar at the top of it when the menu is closed would be sick

I was thinking this also- best case. Will check out ImGui source and see if its possible or not...

@RemainingToast RemainingToast changed the title Add More Bomb Info + ImGui Window Quality of Life Improvements: Bomb Info + Misc Oct 12, 2023
@RemainingToast
Copy link
Author

2023-10-12.23-24-37.1.mp4

Summary

  • Added RenderContext
  • Added Bomb Info Colors
  • Added Show Background Setting
  • Added Show Colors Setting
  • Changed Bomb Info to ImGui Window
  • [QOL] Added 'Escape to Close UI'
  • Added Spectator(s): X Header to Spectator List

@LDzik
Copy link

LDzik commented Oct 12, 2023

Would be nice to have info while bomb is being planted. So i guess you could react faster or expect fake plants.

@RemainingToast
Copy link
Author

Perhaps

@RemainingToast
Copy link
Author

Fixed Conflicts can I please get a review @WolverinDEV

Copy link
Collaborator

@WolverinDEV WolverinDEV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,
thanks for your PR.

In regards to your code, I've left a few comments about stuff I noticed.
I also got some a some general questions:

  1. Why bomb dropped state?
  2. Why a defuse kit count?
    What is the benefit over individually showing for each player if he has a defuse kit?

I also think, I would just make "Escape Closes UI" always on without any settings option

let game_rules = rules_proxy.m_pGameRules()?.read_schema().unwrap();

if game_rules.m_bBombDropped().unwrap_or_default() {
return Ok(Some(C4Info {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ensure, that C_CSGameRulesProxy always comes before a potential C_PlantedC4 entity? I'm not sure if or under what circumstances but this may lead to unexpected results.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the bomb is dropped it can't be planted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should I do?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You first have to loop trough all entities in order to find the C_CSGameRulesProxy entity.
If found & bomb is dropped, then return C4Info with the dropped state.

If not, try to find the bomb entity and get a state from that :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats what Im already doing tho? @WolverinDEV

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for entity_identity in entities.iter() {
            let class_name = ctx
                .class_name_cache
                .lookup(&entity_identity.entity_class_info()?)
                .context("class name")?;

            // Check if bomb is dropped
            if class_name
                .map(|name| name == "C_CSGameRulesProxy")
                .unwrap_or(false)
            {
                /* The bomb is dropped. */
                let rules_proxy = entity_identity
                    .entity_ptr::<C_CSGameRulesProxy>()?
                    .reference_schema()
                    .context("rules proxy missing")?;

                let game_rules = rules_proxy
                    .m_pGameRules()?
                    .reference_schema()
                    .context("game rules missing")?;
                ();

                if game_rules.m_bBombDropped().unwrap_or_default() {
                    return Ok(Some(C4Info {
                        bomb_site: 0,
                        state: C4State::Dropped,
                    }));
                }
            }
            
            .....

controller/src/enhancements/bomb.rs Outdated Show resolved Hide resolved
controller/src/enhancements/bomb.rs Outdated Show resolved Hide resolved
controller/src/enhancements/bomb.rs Outdated Show resolved Hide resolved
controller/src/enhancements/bomb.rs Outdated Show resolved Hide resolved
controller/src/enhancements/bomb.rs Show resolved Hide resolved
controller/src/main.rs Outdated Show resolved Hide resolved
@RemainingToast
Copy link
Author

RemainingToast commented Oct 14, 2023

Why bomb dropped state?

You can't see if the bomb is dropped if you're ct and not close to it, I thought its nice to have

Why a defuse kit count?

Its only used for selecting appropriate color for bomb timer if no kits then its safe after 10 seconds but if theres kits its not safe till 5 seconds

@WolverinDEV
Copy link
Collaborator

Its only used for selecting appropriate color for bomb timer if no kits then its safe after 10 seconds but if theres kits its not safe till 5 seconds

Ahh I missed that one.
I like the idea, but you don't have to loop trough all player controllers and count them.
Instead you can just bail out as soon you've found one with a defuse kit and rename the variable to something like "ct_have_defuse_kit".
You also have to ensure, that the entity which has a defuse kit is still alive. I'm not sure, if a player dies the flag for defuse kit will get cleared instantly :)

@RemainingToast
Copy link
Author

You also have to ensure, that the entity which has a defuse kit is still alive. I'm not sure, if a player dies the flag for defuse kit will get cleared instantly :)

No it didn't I noticed that, is this gonna work: ?

if player_pawn.m_iHealth().unwrap_or(0) != 0 && player_has_defuser {
                self.any_kit = true;
                break;
}

@WolverinDEV
Copy link
Collaborator

No it didn't I noticed that, is this gonna work: ?

if player_pawn.m_iHealth().unwrap_or(0) != 0 && player_has_defuser {
                self.any_kit = true;
                break;
}

You can use m_lifeState on the player pawn (https://www.unknowncheats.me/forum/1265472-post4.html)

}

pub struct BombInfo {
/// Number of Counter-Terrorists with kit
num_kit: u8,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed earlier: ct_has_defuse_kit

defuse.time_remaining, defuse.player_name
),
// Helper Function
fn helper_text_color(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not needed. You can use:

let text_color = if self.local_team == 2 {
  color_t
} else {
  color_ct
};

and instead use ctx.ui.text_colored(text_color, "My lovely text")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still pending

@@ -10,7 +10,7 @@ pub trait Enhancement {
Ok(false)
}

fn render(&self, settings: &AppSettings, ui: &imgui::Ui, view: &ViewController);
fn render(&self, ctx: RenderContext);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still: Please pass RenderContext as reference: &RenderContext

@@ -124,6 +125,14 @@ pub struct UpdateContext<'a> {
pub globals: Globals,
}

#[derive(Clone, Copy)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the Copy derive when you pass RenderContext as reference.

@RemainingToast
Copy link
Author

I'll work on this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants