[WIP] GrimTK GUI Framework

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Slade
Posts: 45
Joined: Tue Oct 21, 2014 6:31 pm

Re: [WIP] GrimTK GUI Framework

Post by Slade »

Now i dont understand..hmm the test dungeon works and when i do all the same things in my dungeon it wont work? Any ideas what im doing wrong? Sorry for these noob questions, im just frustrated sometimes
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: [WIP] GrimTK GUI Framework

Post by Drakkan »

just to let you know - GUI is curently bugged, if you save / load game, GUI got freezed. I am sure John will track this problem down soon :)


btw small request for next version, in case not implemented yet - if GUI is started it will disable AI brains (which makes monster stop attacking you), this was added in last patch.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: [WIP] GrimTK GUI Framework

Post by JohnWordsworth »

I will track down and resolve the issue this weekend. This is why the toolkit is still in alpha ;).

As for freezing brains. That's a good idea - I'll just add it as an option "freezeMonsters" for gui windows (and make it a dialogue option too) so that users can decide whether they want that functionality in their own mods or not.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: [WIP] GrimTK GUI Framework

Post by JKos »

Hi,

I had a pretty hard time trying to figure out how the item atlas works after index number 169 and noticed that you have the same problem in your framework. So to save your time and nerves, here is a working grawItem function:

Code: Select all

function drawItem(g,item,x,y,pAttack)

	local index = item:getGfxIndex()

	if pAttack then
		index = item:getGfxIndexPowerAttack()
	end


	--image indexes in atlas 2 and forward starts from 200 for some reason, not from 170
	--it's simple now when I know it, but figuring it out gave me a headache :)
	local atlasNumber = math.floor(index/200)
	if index >= 200 then 
		index = index - 200 * (atlasNumber)
	end
	local atlasIndex = index%169
	local row = math.floor(atlasIndex/13)
	local col = atlasIndex%13	
	local atlas = 'assets/textures/gui/items.tga'
	if atlasNumber > 0 then
		atlas = 'assets/textures/gui/items_'..(atlasNumber+1)..'.tga'
	end
	--g.drawImage(atlas,0,0)
	g.drawImage2(atlas, x, y, col*75, row*75, 75,75, 75, 75)

end
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: [WIP] GrimTK GUI Framework

Post by AdrTru »

Hi,
I wrote this problem in some post ago. There is my fix( with your %169) in GrimTk file.
mod_assets\grimtk\scripts\gtk\core.lua - line cca 430:

Code: Select all

		self.drawIcon = function(self, args)
			if ( args.position == nil or args.size == nil or args.gfxIndex == nil) then
				Console.warn("Invalid parameters to drawIcon");
				return false;
			end

			local path = args.gfxAtlas;
			local index = args.gfxIndex;
			local atlasWidth = iff(args.atlasWidth, args.gfxAtlasWidth, 13);
			local iconWidth = iff(args.iconWidth,args.iconWidth, 75);
			local iconHeight = iff(args.iconHeight,args.iconHeight, 75);

			if ( path == nil ) then
				local builtInGfxAtlasIndex = math.floor(args.gfxIndex / 200);
				index = index - (builtInGfxAtlasIndex * 200); 
				index = index%169
				
				if ( builtInGfxAtlasIndex == 0 ) then
					path = "assets/textures/gui/items.tga";
				else
					path = "assets/textures/gui/items_" .. (builtInGfxAtlasIndex + 1) .. ".tga";
				end
			end

			local image = {
				path = path,
				origin = { iconWidth * (index % atlasWidth), iconHeight * math.floor(index / atlasWidth) }, 
				size = { iconWidth, iconHeight }
			}

			local imageArgs = {
				image = image,
				position = args.position,
				size = args.size,
				drawMode = args.drawMode,
				imageGravity = args.imageGravity,
			}

			self:drawImage(imageArgs);
		end

My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: [WIP] GrimTK GUI Framework

Post by JohnWordsworth »

Many thanks to both AdrTru and JKos. I will fix the GIcon issue this weekend sometime :).
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: [WIP] GrimTK GUI Framework

Post by JohnWordsworth »

GrimTK GUI Alpha 007 Released.

Release Notes

REALLY IMPORTANT: GrimTK no longer allows you to pass raw function objects to anything as a callback as it caused issues with save games. All of the normal "onPressed", "onSelected", "onFinished" etc hooks should be a string of the form "entity_name.component.function_name", which would usually be something like ...

onPressed = self.go.id .. ".script.function";

If you have been working with the toolkit, you will likely need to make some very minor tweaks. Please see the new demos!

TextInputBox: Added a text input box which can ask the user for a password or a text string.

Added FreezeAI Window Option: You can add "freezeAI" to window definitions to make them freeze monster AI when shown. The NPC dialogue system uses this feature by default.

Bug Fixes: If a text box is in focus, shortcuts shouldn't trigger.

Fixes GIcon: Many thanks for your fix AdrTru. :)
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: [WIP] GrimTK GUI Framework

Post by AndakRainor »

Hello ! Thank you for all this wonderful work :)

I'd like to create some taverns and shops as those in the Ishar games. Basically it would be a background image the size of the screen with some menus. How should I implement it with your framework ? Would it be smart to use a window of maximum size to cover the screen or is there a way to stop the 3D rendering while in those screen size menus ?
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: [WIP] GrimTK GUI Framework

Post by AndakRainor »

Is there any hook I could define which is called before each rendering of a widget ? onDrawGui seems to be called only once.
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: [WIP] GrimTK GUI Framework

Post by Emera Nova »

So I'm making a quest that you have to talk to an NPC to start it and then you meet back up with them when you finish for your reward. Problem is atm the player just has to retalk to the npc and they can get the reward for the quest. How would I make it so it checks to see say either a trigger has been stepped on a button pressed or a monster killed before giving the players the option of saying yes I've completed the quest.

As it is I have the script check to see if you have accepted the quest if you have it changes the dialogue to different stuff which gives you access to turning in the quest as completed.. But I have no way atm of checking to see if it really is complete to give that option.
Post Reply