Git Product home page Git Product logo

Comments (4)

veeenu avatar veeenu commented on August 12, 2024

Could you please elaborate on your request? It's not super clear.

I'm not sure where such a feature would belong in the current API -- it seems like it has nothing to do with hudhook and it depends on imgui instead.

For the record, font size can be controlled already by the clients, see this, but again it is not strictly dependent on hudhook and it is a feature from imgui.

If you mean changing the font size across widgets in the same frame, I don't think that is supported by imgui outside of pushing/popping preinitialized fonts. Fonts are rasterized to a texture at initialization time, and that texture then gets sampled when drawing text.

from hudhook.

luadebug avatar luadebug commented on August 12, 2024

ImGui::GetBackgroundDrawList()->AddText(esp_text, 19, ImVec2(ESPLeft, ESPTop - 20.f), ImColor(var::enemyColor[0], var::enemyColor[1], var::enemyColor[2]), Enemy->Name);
This C++ code does not use any push or either pop for font, and second parameter being passed is text size. I was assuming that asking here is much better idea, rather go to imgui-rs that is being abandoned for months.
imgui-rs/imgui-rs#787

from hudhook.

luadebug avatar luadebug commented on August 12, 2024
// 200 IQ conversion mechanism
pub fn f32_to_u8(value: f32) -> u8 {
    // Scale and clamp the value to the range [0, 255]
    let scaled = (value * 255.0).clamp(0.0, 255.0);
    scaled as u8
}

                        unsafe {
                                let custom_font = ui.push_font(font_id);
                                // Get the entity name and create a CString
                                let text = entity.name().unwrap();
                                let c_text = CString::new(text).unwrap();  // Convert to C-compatible string

                                let font_handle = igGetFont();

                                // Get the pointer to the C string
                                let start: *const c_char = c_text.as_ptr();  // Use CString to ensure null termination

                                // The end pointer is not necessary when using CString, as you can pass the string slice
                                let end: *const c_char = start.add(c_text.as_bytes().len());

                                // Call the function
                                sys::ImDrawList_AddText_FontPtr(
                                    sys::igGetBackgroundDrawList_Nil(),
                                    font_handle,
                                    SETTINGS.deref().name_text_thickness,
                                    ImVec2::from([espleft, esptop - 80.0f32]),
                                    if LOCAL_PLAYER.team().unwrap() == entity.team().unwrap() {
                                        ImColor32::from_rgba(f32_to_u8(SETTINGS.deref().ally_name_text_color[0]), f32_to_u8(SETTINGS.deref().ally_name_text_color[1]), f32_to_u8(SETTINGS.deref().ally_name_text_color[2]), f32_to_u8(SETTINGS.deref().ally_name_text_color[3])).to_bits()
                                    } else {
                                        ImColor32::from_rgba(f32_to_u8(SETTINGS.deref().enemy_name_text_color[0]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[1]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[2]), f32_to_u8(SETTINGS.deref().enemy_name_text_color[3])).to_bits()
                                    },
                                    start,
                                    end,
                                    0.0f32,
                                    std::ptr::null()  // Assuming you don't want to specify a clipping rectangle
                                );
                                custom_font.pop();
                            }

When I drag slider that is bound to name_text_thickness I am able to change text size during this function call. What resolves my problem.

from hudhook.

luadebug avatar luadebug commented on August 12, 2024

That seems to be part of imgui-rs.

from hudhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.