October 04, 2023, 06:20:08 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Due to a rise in bot activity, new posters need to be approved before posting.

Join the community Discord server!

Pages: 1 [2] 3 4

Author Topic: Custom HUD WarHUD (Drop shadows! Damage indicator compatibility!)  (Read 13138 times)

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud
« Reply #15 on: June 25, 2012, 10:30:01 am »

No, it's set up not to conflict. I used both at the same time while developing. The key variable is overwritten before being used in both plugins.
« Last Edit: June 25, 2012, 10:32:10 am by Chartreuse »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

RedBluYellow

  • Guest
Re: WIP HUD warhud
« Reply #16 on: June 25, 2012, 11:28:28 am »

Looks like a nice hud, simple and clean
Logged

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3657
    • My own website
Re: WIP HUD warhud
« Reply #17 on: June 25, 2012, 01:38:19 pm »

No, it's set up not to conflict. I used both at the same time while developing. The key variable is overwritten before being used in both plugins.
I think that it will conflict actually. One of the options will be written to the wrong key.
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud
« Reply #18 on: June 25, 2012, 01:39:28 pm »

It hasn't happened to me yet, and I've been messing with my options all the time. The keys haven't crossed yet. I don't know how.
[Plugins]
DmgInd_style=0
DmgInd_sound=1
DmgInd_indicator_style=0
DmgInd_place=1

[Plugins/warhud/]
WarHUD_style=1
This is in my ini right now. If they were conflicting, one of the style keys would be in the other section.

If you can make a conflict happen I'll figure out why it's not happening for me, then give my key var a unique name.
« Last Edit: June 25, 2012, 01:42:55 pm by Chartreuse »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud
« Reply #19 on: June 25, 2012, 01:50:24 pm »

I made a conflict happen and figured out why it wouldn't for me.
I was assuming the key was the only thing conflicting, because that's the only thing people were talking about. But the section is conflicting too, so the damage indicator style was saving under my HUD's style instead. Side effect, the indicator style refused to save properly.
Solution, I'll just put warhud_ at the start of those vars.
Code: [Select]
//Complete overhaul to GG2's HUD. Inspired by RevanXP's TF2 HUD. ISC license.
//View/edit with a fixed width font. Some punctuation is vertically aligned.
global.warhud_namespace = "Plugins/warhud/";


//Set up first

ini_open("gg2.ini");
global.warhud_style = ini_read_real(global.warhud_namespace,"WarHUD_style",1);
ini_close();

//make a new menu for plugin options
if !variable_global_exists("pluginOptions") {
    global.pluginOptions = object_add();
    object_set_parent(global.pluginOptions,OptionsController); 
    object_set_depth(global.pluginOptions,-130000);
    object_event_add(global.pluginOptions,ev_create,0,'   
        menu_create(40, 140, 300, 200, 30);
       
        if room != Options {
            menu_setdimmed();
        }
       
        menu_addback("Back", "
            instance_destroy();
            if(room == Options)
                instance_create(0,0,MainMenuController);
            else
                instance_create(0,0,InGameMenuController);
        ");
    ');
   
    object_event_add(InGameMenuController,ev_create,0,'
        menu_addlink("Plugin Options", "
            instance_destroy();
            instance_create(0,0,global.pluginOptions);
        ");
    ');
}

//add menu option/s
object_event_add(global.pluginOptions,ev_create,0,'
    //very dumb workaround
    warhud_section = global.warhud_namespace;
    warhud_key1 = "WarHUD_style";
    //even dumber workaround
    quote = chr(39);
   
    menu_addedit_select("WarHUD dropshadow style", "global.warhud_style", "
        gg2_write_ini(warhud_section, warhud_key1, argument0);
    ");
    menu_add_option(0, "Off");
    menu_add_option(1, "Team colored");
    menu_add_option(2, "Black");
');

//HUD stuff now

object_event_add(HealthHud,ev_create,0,"
    sprite_index = sprite_add_sprite(global.warhud_namespace + 'CharacterHUD.gmspr');
    health_sprite = sprite_add_sprite(global.warhud_namespace + 'Healthbar.gmspr');
    offwhite  = make_color_rgb(217,217,183); // Old (too light) color values ripped from stock HUD:
    c_redteam = make_color_rgb( 42, 24, 16); // (165, 70, 64);
    c_bluteam = make_color_rgb( 16, 32, 64); // ( 73, 93,104); (They might be useful to someone.)
");

object_event_clear(HealthHud,ev_draw,0);
object_event_add(HealthHud,ev_draw,0,"
    if(global.myself.object == -1)
    {
        instance_destroy();
        exit;
    }
   
    text_xpos = 45+24;
    text_ypos = 547+18;
    sprite_xpos = 11;
    sprite_ypos = 525;
    icon_xpos = 11;
    icon_ypos = 545;
    hp = global.myself.object.hp;
    maxHp = global.myself.object.maxHp;
    event_user(0);
   
    //health icon outline and backing
    draw_sprite_ext(sprite_index , 0, view_xview[0]+sprite_xpos, view_yview[0]+sprite_ypos, 2, 2, 0, c_white, 1);
    draw_sprite_ext(health_sprite, 0, view_xview[0]+sprite_xpos, view_yview[0]+sprite_ypos, 2, 2, 0, c_black, 1);
   
    //draw dynamic colored health icon
    //TODO: Optimize to one sprite draw
    hppixels = hp/maxHp*17;
    draw_sprite_part_ext(health_sprite,0,0,(17-hppixels)+10,sprite_width,hppixels+1,view_xview[0]+icon_xpos, view_yview[0]+icon_ypos+(17-hppixels)*2,2,2,c_red,1);
    draw_sprite_part_ext(health_sprite,0,0,(17-hppixels)+10,sprite_width,hppixels+1,view_xview[0]+icon_xpos, view_yview[0]+icon_ypos+(17-hppixels)*2,2,2,c_green,hp/maxHp);
   
    //start picking HP # text colors
    if(global.myself.team == TEAM_RED)
        c_shadow = c_redteam;
    if(global.myself.team == TEAM_BLUE)
        c_shadow = c_bluteam;
    if(global.warhud_style == 2)
        c_shadow = $202020; //offblack
   
    //colors for HP # text, red = can die in one hit; orange = taking too much heat
    if(hp <= 55)
        hpColor = c_red;
    else if(hp <= (maxHp/2))
        hpColor = c_orange;
    else
        hpColor = offwhite;
   
    draw_set_valign(fa_center);
    draw_set_halign(fa_left);
    hpText = string(ceil(max(hp,0)));
    size = 3;
   
    if(global.warhud_style)
        draw_text_transformed_color(view_xview[0]+text_xpos+size, view_yview[0]+text_ypos+size, hpText, size, size, 0, c_shadow, c_shadow, c_shadow, c_shadow, 1);
    draw_text_transformed_color(view_xview[0]+text_xpos, view_yview[0]+text_ypos, hpText, size, size, 0, hpColor, hpColor, hpColor, hpColor, 1);
");
« Last Edit: June 25, 2012, 01:54:34 pm by Chartreuse »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3657
    • My own website
Re: WIP HUD warhud
« Reply #20 on: June 25, 2012, 02:05:51 pm »

updated my plugin.

Also you don't need this in your code:
Code: [Select]
//even dumber workaround
    quote = chr(39);

That was so that i could write "wareya's" and "lorgan's" in the options menu
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud
« Reply #21 on: June 25, 2012, 02:08:19 pm »

Thanks for the heads up. I didn't notice that I wasn't using it, and it didn't stick out for me.
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Footpöp

  • Veteran Member
  • ******
  • Karma: 24
  • Offline Offline
  • Posts: 4088
  • I /saw/ him
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #22 on: June 27, 2012, 01:24:40 pm »

Code: [Select]
___________________________________________
ERROR in
action number 1
of Draw Event
for object HealthHud:

Trying to draw non-existing sprite.

___________________________________________
wat :y
Logged
Team /ABC/

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3657
    • My own website
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #23 on: June 27, 2012, 01:40:30 pm »

Code: [Select]
___________________________________________
ERROR in
action number 1
of Draw Event
for object HealthHud:

Trying to draw non-existing sprite.

___________________________________________
wat :y
You need the sprites to use this obviously.
Download them from git.
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

Footpöp

  • Veteran Member
  • ******
  • Karma: 24
  • Offline Offline
  • Posts: 4088
  • I /saw/ him
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #24 on: June 27, 2012, 01:54:38 pm »

thanks
Logged
Team /ABC/

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #25 on: July 08, 2012, 01:23:40 am »

I don't want to make it myself (I personally dislike garmin hud and don't think the center-oriented thing fits GG2), but anyone with basic coding knowledge can just pick this HUD up and make whatever they want based on it. It's ISC licensed which basically means that anyone can take any of my code and do absolutely whatever they want with it.

Also, I haven't started work on the ammo HUDs yet, because I need a large chunk of dedicated time during which to do so. It's a lot of tedious work removing stuff, and the original stuff is all in scripts, which makes my job harder. I'll be away from home for a month starting on the 25th, perhaps I'll be able to do it then.
« Last Edit: July 08, 2012, 01:27:38 am by Chartreuse »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #26 on: March 18, 2013, 02:51:06 pm »

I updated the plugin.
+ fix a memory leak
+ syntax changes
+ an optimization
+ license clarification

Here: https://github.com/wareya/warhud

Or (for upgrades):
Code: (warhud.gml) [Select]
//Complete overhaul to GG2's HUD. Inspired by RevanXP's TF2 HUD. Code which isn't from GG2 itself is ISC licensed. Code which is from GG2 is GPL v3 licensed.
//View/edit with a fixed width font. Some code is vertically aligned.
global.warhud_namespace = "Plugins/warhud/";
global.warhud_hpcross_box = sprite_add_sprite(global.warhud_namespace + 'CharacterHUD.gmspr');
global.warhud_hpcross = sprite_add_sprite(global.warhud_namespace + 'Healthbar.gmspr');

//Set up first

ini_open("gg2.ini");
global.warhud_style = ini_read_real(global.warhud_namespace,"WarHUD_style",1);
ini_close();

//make a new menu for plugin options
if !variable_global_exists("pluginOptions") {
    global.pluginOptions = object_add();
    object_set_parent(global.pluginOptions,OptionsController); 
    object_set_depth(global.pluginOptions,-130000);
    object_event_add(global.pluginOptions,ev_create,0,'   
        menu_create(40, 140, 300, 200, 30);
       
        if room != Options {
            menu_setdimmed();
        }
       
        menu_addback("Back", "
            instance_destroy();
            if(room == Options)
                instance_create(0,0,MainMenuController);
            else
                instance_create(0,0,InGameMenuController);
        ");
    ');
   
    object_event_add(InGameMenuController,ev_create,0,'
        menu_addlink("Plugin Options", "
            instance_destroy();
            instance_create(0,0,global.pluginOptions);
        ");
    ');
}

//add menu option/s
object_event_add(global.pluginOptions,ev_create,0,'
    //very dumb workaround
    warhud_section = global.warhud_namespace;
    warhud_key1 = "WarHUD_style";
   
    menu_addedit_select("WarHUD dropshadow style", "global.warhud_style", "
        gg2_write_ini(warhud_section, warhud_key1, argument0);
    ");
    menu_add_option(0, "Off");
    menu_add_option(1, "Team colored");
    menu_add_option(2, "Black");
');

//HUD stuff now

object_event_add(HealthHud,ev_create,0,"
    sprite_index  = global.warhud_hpcross_box;
    health_sprite = global.warhud_hpcross;
    c_offwhite  = make_color_rgb(217,217,183); // Old (too light) color values ripped from stock HUD:
    c_redteam   = make_color_rgb( 42, 24, 16); // (165, 70, 64);
    c_bluteam   = make_color_rgb( 16, 32, 64); // ( 73, 93,104); (They might be useful to someone.)
    c_offblack  = $202020;    //( 32, 32, 32);
");

object_event_clear(HealthHud,ev_draw,0);
object_event_add(HealthHud,ev_draw,0,"
    if(global.myself.object == -1)
    {
        instance_destroy();
        exit;
    }
   
    text_xpos = 45+24;
    text_ypos = 547+18;
    sprite_xpos = 11;
    sprite_ypos = 525;
    icon_xpos = 11;
    icon_ypos = 545;
    hp = global.myself.object.hp;
    maxHp = global.myself.object.maxHp;
    scale = 2;
    event_user(0);
   
    //health icon outline and backing
    draw_sprite_ext(sprite_index , 0, view_xview[0]+sprite_xpos, view_yview[0]+sprite_ypos, scale, scale, 0, c_white, 1);
    draw_sprite_ext(health_sprite, 0, view_xview[0]+sprite_xpos, view_yview[0]+sprite_ypos, scale, scale, 0, c_black, 1);
   
    //draw dynamic colored health icon
    //TODO: Optimize to one sprite draw w/ prepared color blend
    icon_yoffset = 10;
    icon_ysize = 17;
    hppixels = hp/maxHp*17;
   
    draw_sprite_part_ext(health_sprite,0,0,(icon_ysize-hppixels)+icon_yoffset,sprite_width,hppixels+1,view_xview[0]+icon_xpos, view_yview[0]+icon_ypos+(icon_ysize-hppixels)*scale,scale,scale,merge_color(c_red,c_green,hp/maxHp),1);
   
    //start picking HP # text colors
    if(global.myself.team == TEAM_RED)
        c_shadow = c_redteam;
    if(global.myself.team == TEAM_BLUE)
        c_shadow = c_bluteam;
    if(global.warhud_style == 2 or (hp <= 55 or hp <= maxHp/2 and global.myself.team == TEAM_BLUE))
        //logic to prevent blue on red hue clashing at low health on blu team w/ team colored dropshadow option
        c_shadow = c_offblack; //offblack
   
    //colors for HP # text, red = can die in one hit; orange = taking too much heat
    if(hp <= 55)
        hpColor = c_red;
    else if(hp <= maxHp/2)
        hpColor = c_orange;
    else
        hpColor = c_offwhite;
   
    draw_set_valign(fa_center);
    draw_set_halign(fa_left);
    hpText = string(ceil(max(hp,0)));
    size = 3;
   
    if(global.warhud_style)
        draw_text_transformed_color(view_xview[0]+text_xpos+size, view_yview[0]+text_ypos+size, hpText, size, size, 0, c_shadow, c_shadow, c_shadow, c_shadow, 1);
    draw_text_transformed_color(view_xview[0]+text_xpos, view_yview[0]+text_ypos, hpText, size, size, 0, hpColor, hpColor, hpColor, hpColor, 1);
");
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Tornadoblitz

  • Guest
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #27 on: March 18, 2013, 03:22:31 pm »

Also, I haven't started work on the ammo HUDs yet.
Do you have any thoughts on how it would look so far?
Logged

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12699
  • Another one --
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #28 on: March 18, 2013, 03:26:53 pm »

Also, I haven't started work on the ammo HUDs yet.
Do you have any thoughts on how it would look so far?
http://i.imgur.com/l7Msytt.jpg
A number of the current ammo in your clip (if your class has a magazine type weapon eg not heavy) and a chargebar for either how much ammo you have (for classes with charge reloading) or the time to your next shot (for classes without any reloading)
« Last Edit: March 18, 2013, 03:29:44 pm by Phantom Brave »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Dusty

  • 2012 Haxxy Award Winner
  • *
  • Karma: -78
  • Offline Offline
  • Posts: 11006
  • Dust in a box under a table
Re: WIP HUD warhud (Drop shadows! Damage indicator compatibility!)
« Reply #29 on: March 18, 2013, 05:38:02 pm »

Also, I haven't started work on the ammo HUDs yet.
Do you have any thoughts on how it would look so far?
http://i.imgur.com/l7Msytt.jpg
A number of the current ammo in your clip (if your class has a magazine type weapon eg not heavy) and a chargebar for either how much ammo you have (for classes with charge reloading) or the time to your next shot (for classes without any reloading)
Or just simplify it to be a number for heavy/pyro as well.
I'd rather know that I can use my air/flareblast by checking the number
Pages: 1 [2] 3 4
 

Page created in 0.061 seconds with 51 queries.