Skip to content

Instantly share code, notes, and snippets.

@blind-coder
Created June 21, 2015 18:11
Show Gist options
  • Save blind-coder/3acbfe028b7426492bfc to your computer and use it in GitHub Desktop.
Save blind-coder/3acbfe028b7426492bfc to your computer and use it in GitHub Desktop.
Project Zomboid ISRichText in a ISCollapsableWindow
function BCMapMod.onResize(self)
ISCollapsableWindow.onResize(self);
self.panel:setWidth(self:getWidth());
self.panel:setHeight(self:getHeight() - (self:titleBarHeight() + self:resizeWidgetHeight()));
self.panel:onResize();
self.richtext:setWidth(self.panel:getWidth());
self.richtext:setHeight(self.panel:getHeight());
self.richtext:onResize();
self.richtext.maxLineWidth=self.panel:getWidth() - (self.richtext.marginLeft + self.richtext.marginRight + self.richtext.vscroll:getWidth());
end
function BCMapMod.createWindowStuff(player) -- {{{
local m = ISCollapsableWindow:new(100, 100, 150, 100);
m:setVisible(true);
local p = ISPanel:new(0, m:titleBarHeight(), m:getWidth(), m:getHeight() - (m:titleBarHeight() + m:resizeWidgetHeight()));
p:initialise();
local r = ISRichTextPanel:new(0, 0, p:getWidth(), p:getHeight());
r:initialise();
r.text = "Foo <LINE> Bar <LINE> The quick <RED> RED <RGB:1,1,1> fox was too lazy to jump over the dog. <LINE> ";
for x=1,10 do
r.text = r.text .. "All work and no play make "..getSpecificPlayer(0):getForname().." a dumb boy. <LINE> ";
end
r.autosetheight = false;
r.clip = true;
r:ignoreHeightChange();
r:addScrollBars();
r:paginate();
p:addChild(r);
m.panel = p;
m.richtext = r;
m:addChild(p);
m:addToUIManager();
m.onResize = BCMapMod.onResize;
end
-- }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment