Jump to content

Display tooltip for text written in sheet of paper or post-it notes (Hydrocraft)


ErDroid

Recommended Posts

As the title says, sometimes you want to make it quick to read the text of a sheet of paper or more specifically the post-it notes without having to right click- left click on read and wait for the windows to appear. The tooltip might not show the whole text but a portion. No need to create a whole "tooltip class object" but to reuse the existing one.

I would kindly try to make a mod out of it.. But I would need some kickstarter tips :)

Regards

Link to comment
Share on other sites

Nvm I just made the mod myself (sort of ). After reading the API and learning from comparison to other code.. I made the above possible. It needs polishing (such as resizing window with width and height of the text, or just display a few lines of the text written in the sheet of paper), etc. Anyway IF SOMEONE really needs this mod, just pm here and I will upload it to my github repository and not to the workshop since it's still a WIP because of the aforementioned polishing needs of the mod.

Meanwhile, for those that can handle some minor modding. I just let you the code you have to modify from "ISToolTipInv.lua" which is found in "\media\lua\client\ISUI" in your root folder:

Anyway I just uploaded the lua file that I use in my mod.

Key modifications/addons of code are in line 87: This just stores a var of the spacing of the font that will be used to write in the tooltip

local lh = getTextManager():getFontFromEnum(UIFont.Small):getLineHeight();

and line 94: Here's the magic. Test if the item "mouse-hovered" is a post-it or a sheet of paper, then calculates the number of items in the original tooltip and adds it to a calculation of the position of my label (so as to display my stuff just below everything else). Then it stores the text of the first page of the postit or sheet in "label" and draws it in the label_position calculated before)
 

if self.item:getType() == "HCPostit" or self.item:getType() == "SheetPaper2" then
		
		local items_count = math.floor((self.tooltip:getHeight() / lh) - 1); -- calculate number of actual items in tooltip.
		local label_pos = lh * 1.5 + (lh * (items_count));
		
		
		if  self.item:seePage(1) ~= nil then
		
			local label=self.item:seePage(1);
			self.tooltip:DrawText(label, 5, label_pos, 1, 1, 0.8, 1);
			tw = tw + 60;
			th= th+30;
		end
	end

That's it
PD: I loved the insert code feature of these forums :P

ISToolTipInv.lua

Edited by ErDroid
Link to comment
Share on other sites

I Sort of Updated the mod so as to make it that all PostItNotes will have only two lines max and only 30  characters max. When you write you will only be able to  make 2 new lines and if you go over the 30 characters, the text will be erased and you will be put at the beginning of the text field.  In the future I might just make it so you can auto wrap the text at "x" width of the textfield.. But this work too. I don't think I will improve it any further for now... Unless someone specifically asked me to do so..

So here is the other file you will have to modify for that to work: ISUIWriteJorunal.lua , which is in the same folder of IsToolTipInv.lua

The small modification is in the line 58:
 

	if self.notebook:getType() == "HCPostit" then
		
		self.lineNumber=2;
		self.entry:setMaxTextLength(30);
	
	end

 

ISUIWriteJournal.lua

Link to comment
Share on other sites

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
×
×
  • Create New...