• entries
    707
  • comments
    1173
  • views
    433354

AWESOME

Sign in to follow this  
Programmer16

73 views

So, I was thinking "Hey, redesigning my HUD would be 10 times easier if I had a layout system." So...I made a layout system lol. Here's the code I was using to make the HUD:

Hud = ParentGame->Environment.AddControl(new dft::Gui::Solid(0, 0, true));
Hud->Visible = true;

HealthBar = Hud->AddChild(new dft::Gui::Bar(16, 52, 127, 26, 0, PlayerChar.CurrentStats.Health, dft::Graphics::Color::Red, true));
HealthBar->Visible = true;

WeaponIcon = Hud->AddChild(new dft::Gui::Image(8, 8, 97, 32, "Graphics/weapons.png", Rectangle(0, 0, 97, 32), true));
WeaponIcon->Visible = true;

AmmoCountLabel = Hud->AddChild(new dft::Gui::Label(108, 26, 52, 14, "", "Ammo Count", Hud, true));
AmmoCountLabel->Visible = true;
AmmoCountLabel->FontFormatting = dft::Graphics::FontFormatting::Center | dft::Graphics::FontFormatting::VCenter;
AmmoCountLabel->FontName = "default";
AmmoCountLabel->FontColor = dft::Graphics::Color::Red;

AmmoTypeLabel = Hud->AddChild(new dft::Gui::Label(108, 8, 52, 14, "Normal", "Ammo Type", Hud, true));
AmmoTypeLabel->Visible = true;
AmmoTypeLabel->FontFormatting = dft::Graphics::FontFormatting::Center | dft::Graphics::FontFormatting::VCenter;
AmmoTypeLabel->FontColor = dft::Graphics::Color::Red;
AmmoTypeLabel->Text = AmmoTypes::ToString(PlayerChar.CurrentAmmoType);

PlayerScoreLabel = Hud->AddChild(new dft::Gui::Label(208, 8, 142, 30, "1200000", "Player's Score", Hud, true));
PlayerScoreLabel->Visible = true;
PlayerScoreLabel->FontFormatting = dft::Graphics::FontFormatting::Right | dft::Graphics::FontFormatting::VCenter;
PlayerScoreLabel->FontName = "DigitalReadout";
PlayerScoreLabel->FontColor = dft::Graphics::Color::Red;
PlayerScoreLabel->Text = Int::ToString(PlayerScore);



Not pleasant, to say the least. And then all of the recompiling to move controls around, etc. Anyway, here's the new code and the accompanying layout file:

ParentGame->Environment.LoadLayoutFile("Resources/test_layout.layout");
Hud = ParentGame->Environment.FindControl("MainHUD");
HealthBar = ParentGame->Environment.FindControl("HealthBar");
WeaponIcon = ParentGame->Environment.FindControl("WeaponIcon");
AmmoCountLabel = ParentGame->Environment.FindControl("AmmoCountLabel");
AmmoTypeLabel = ParentGame->Environment.FindControl("AmmoTypeLabel");
PlayerScoreLabel = ParentGame->Environment.FindControl("PlayerScoreLabel");





"1.0" ?>

"MainHUD" X='0' Y='0' SkinClass="HUD" />
"HealthBar" X='16' Y='90' Width='127' Height='26' MinimumValue='0' MaximumValue='100' Color="Rgb(255, 0, 0)" Parent="MainHUD" />
"WeaponIcon" X='8' Y='46' Width='97' Height='32' TexturePath="Graphics/weapons.png" SourceRectangle="Rectangle(0,0,97,32)" Parent="MainHUD" />





Works really well so far. I can say that I totally do not regret writing all of the ToString() and FromString() functions for my different data types.

Now I'm off to redesign my HUD. Oluseyi pointed out that the old one was kind of bland and didn't really display the info well. So, I'm going to read some stuff that he linked me too and hopefully I can come up with something decent.

-edit-
Also, I'm taking out different ammo types. Having them in is really throwing a kink in things.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now