Jump to content

GorzenDev

Members
  • Posts

    141
  • Joined

  • Last visited

Profile Information

  • Location
    Netherlands

Recent Profile Visitors

8,228 profile views

GorzenDev's Achievements

Newbie

Newbie (1/14)

92

Reputation

5

Community Answers

  1. if i remember correctly you need the GUI to initialize the image. example: logo = Widget::Panel( 0, 0, gui->GetBase()->GetClientSize().width, gui->GetBase()->GetClientSize().height, gui->GetBase()); logo->SetScript("Scripts/GUI/Custom/ImagePanel.lua"); Image* logoImg = gui->LoadImageA("Materials/Logo/leadwerks_logo.tex"); logo->SetImage(logoImg); logo->Redraw(); logoImg->Release();
  2. using a global variable like that will result in undefined behaviour. make sure you process each event before the while loop ends. you would be better off to store a pointer to mudaLocalGui as global variable, add a process function to your script, and call it from your event loop. (remove the pointer after closing the menu ) personally i would use some kind of guimanager script, instead of processing your events in Main.lua. example of a gui manager: import("Scripts/MainMenu.lua") import("Scripts/GameMap.lua") import("Scripts/GameGUI.lua") function BuildGUIManager(context) local Manager = {} -- Manager.gamemenu = BuildMenu(context, Manager) Manager.gamemenu:Show() -- Manager.gamemap = BuildGameMap(context) Manager.gamemap:Hide() -- Manager.gameui = BuildGameGUI(context, Manager) Manager.gameui:Hide() ------------------------------------------------ function Manager:MenuHidden() return self.gamemenu:Hidden() end function Manager:ShowGameMenu() self.gamemenu:Show() self.gameui:Hide() end function Manager:HideGameMenu() self.gameui:Show() self.gamemenu:Hide() end -- function Manager:Update() -- if self.gamemenu:Hidden() == false then self.gamemenu:Update() end if self.gamemap:Hidden() == false then self.gamemap:Update() end if self.gameui:Hidden() == false then self.gameui:Update() end -- while EventQueue:Peek() do local event = EventQueue:Wait() local event_processed = false --process menu if self.gamemenu:Hidden() == false then if self.gamemenu:ProcessEvent(event) == false then --exit game return false end end --process map if self.gamemap:Hidden() == false then event_processed = self.gamemap:ProcessEvent(event) end --process ui if event_processed == false and self.gameui:Hidden() == false then self.gameui:ProcessEvent(event) end end -- return true end -- -- return Manager end
  3. i used to do something like this... this will only add keyinfo to the Keys table when a key is actually used. to make it work you would need to add a call to PreUpdate() in your main loop. to check a key's state you would call eg: IsKeyUp(Key.W) or IsKeyDown(Key.W). function SetKeyboardInfoPack() local pack = { Keys = {}, -- FlushKeyInfo = function (self, resetHit, key) if key ~= nil then local nHit = 0 if self.Keys[key] ~= nil and resetHit == false then nHit = self.Keys[key].hit end self.Keys[key] = {down = false, up = false, hit = nHit} else local nHit = 0 for key,value in pairs(self.Keys) do if resetHit == false then nHit = self.Keys[key].hit end self.Keys[key] = {down = false, up = false, hit = nHit} end end end, -- PreUpdate = function (self) self:RefreshKeyStates() end, -- IsKeyDown = function (self, key) --create a key record if not already exists and check the keystate if self.Keys[key] == nil then self.Keys[key] = {down = false, up = false, hit = 0} self:RefreshKey(key) end --return keystate return self.Keys[key].down end, -- IsKeyUp = function (self, key) --create a key record if not already exists and check the keystate if self.Keys[key] == nil then self.Keys[key] = {down = false, up = false, hit = 0} self:RefreshKey(key) end --return keystate return self.Keys[key].up end, Keyhits = function (self, key) --create a key record if not already exists and check the keystate if self.Keys[key] == nil then self.Keys[key] = {down = false, up = false, hit = 0} self:RefreshKey(key) end --return keystate return self.Keys[key].hit end, -- RefreshKeyStates = function (self) for key,value in pairs(self.Keys) do self:RefreshKey(key) end end, RefreshKey = function (self, key) if key ~= nil then if self.Keys[key] ~= nil then if window:KeyDown(key) then self.Keys[key].down = true self.Keys[key].up = false elseif self.Keys[key].down == true then --last state down self.Keys[key].down = false self.Keys[key].up = true self.Keys[key].hit = self.Keys[key].hit + 1 elseif self.Keys[key].up == true then --last state up self.Keys[key].down = false self.Keys[key].up = false end end end end } -- return pack end
  4. they all definitly work no doubt about it. are you certain that the variable you try to read/write actually exists in the widget script?? i assume you are looking for. widget:SetFloat("radius", 2); widget:GetFloat("radius"); REMEMBER !!! call widget:Redraw() when you change a variable's value. often you would think "hey this does not work" while it usually does work but is not updated yet ?
  5. The BaseActor class i use to derive actors from. Use it just like you would use a entity script. Attach actor to a entity. baseActor = new BaseActor(); entity->SetActor(baseActor); BaseActor.h #include "Leadwerks.h" using namespace Leadwerks; const enum class ActorType : char { Base, Player, NPC}; class BaseActor : public Actor { //Built-in extendable functions // //virtual void EndAnimation(const int sequence); virtual void Sleep(); //virtual void Wake(); virtual void Attach(); //virtual void Detach(); //virtual void Collision(Entity* entity, const Vec3& position, const Vec3& normal, float speed); virtual void UpdateWorld(); virtual void UpdatePhysics(); //virtual void UpdateMatrix(); virtual void PostRender(Context* context); //virtual void Draw(); //virtual void DrawEach(Camera* camera); //virtual void ReceiveSignal(const std::string& inputname, Entity* sender); public: ActorType actorType = ActorType::Base; BaseActor(); virtual ~BaseActor(); }; BaseActor.cpp #include "BaseActor.h" BaseActor::BaseActor() { } BaseActor::~BaseActor() { } void BaseActor::Attach() { // //System::Print("BaseActor Attached."); } void BaseActor::Sleep() { // //System::Print("BaseActor Sleep."); } void BaseActor::UpdateWorld() { //System::Print("BaseActor UpdateWorld."); } void BaseActor::UpdatePhysics() { //System::Print("BaseActor UpdatePhysics."); } void BaseActor::PostRender(Context* context) { // }
  6. Definition Entity.h virtual int FindAnimationSequence(const std::string& sequence);//lua Entity::FindAnimationSequence("sequencename")
  7. whenevver i loose my motivation i actually force myself to do at least 4 hours of coding each week. which in turn motivates me because i progress. (even if its just small progress) this brings me in a vicious circle that keeps me going.
  8. You could always edit the "common" template and remove the files you dont want to be copied. Dont forget to backup before editing.
  9. create your own "BlankProject" template its very easy and saves you a lot of time. i remember i made a post somewhere on how to do it.
  10. The style system change results in a lot of manual source updating and since i make use of the GUI system in basicly all of my projects, that's alot of code to change. Maiby i will have to write a small tool that does it for me... i guess notepad++ could achieve it nonetheless nice work on the update.
  11. GorzenDev

    Project Release

    I decided to release the source/project for my GUIEditor. its an unfinished project and not at all optimized, although it is usable. you mite have to upgrade the source project to the latest version. written in c++. the project includes some custom gui scripts found in /Scripts/GUI/Custom. and a FileDialog i designed using widgets. GUIEditor.rar enjoy
  12. you could create your own pre-post processor function in your main.lua, and have that execute when you want.
  13. i'm thinking this is due to NVIDIA trying to force/overwrite game settings when you manually set them. try using default nvidia settings and let leadwerks do its thing...
  14. that is one option. i recommend moving the event loop outside of the menu file though. then call processevent(event) with a return value on any table that needs to process events. for example in my current c++ project i actualy have a class called GUIManager which holds the event loop. which in turn calls other gui classes to update and grab events. when that call returns true then the event is processed and there is no need to call other classes with that event. example code(C++) : //Handle GUI events while (EventQueue::Peek()) { Event event = EventQueue::Wait(); // //Update menu UI events if (!gamemenu->Hidden()) { //exit game if (gamemenu->ProcessEvent(event) == false) return false; } //update game UI events if (!gameui->Hidden()) gameui->ProcessEvent(event); }
  15. you can create multiple GUI to hold widgets. but only one event loop can be used.
×
×
  • Create New...