Renderer questions and requests
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting. You may
to help finance the hosting costs of this forum.
Please read the Forum rules and policies before posting. You may

Renderer questions and requests
As I was investigated the code to make a "simple" dialogue system (one that could be embedded in ESB easily)
(ian_scho's is to complicated for me event though it's very powerful), I have a few questions:
1) I couldn't find a function to return the character portrait (as a bitmap).
I find two uses to this:
- Make custom displays of character portraits
- Being able to make alterations to portraits without entirely replacing them with dsb_replace_portrait() using the draw functions
2) Is there a way to override the viewport ? (without overriding the full screen)
3) I see the dsb_fullscreen locks the game. Is there any way to "decouple" the screen drawing from the game locking ?
4) Is the lock done with "dsb_lock()" equivalent to the implicit lock in "dsb_fullscreen()" ?
5) Also, sys_inventory_enter() etc. function are called after the inventory is entered, is it still possible to interrupt/override the inventory screen display ?
(ian_scho's is to complicated for me event though it's very powerful), I have a few questions:
1) I couldn't find a function to return the character portrait (as a bitmap).
I find two uses to this:
- Make custom displays of character portraits
- Being able to make alterations to portraits without entirely replacing them with dsb_replace_portrait() using the draw functions
2) Is there a way to override the viewport ? (without overriding the full screen)
3) I see the dsb_fullscreen locks the game. Is there any way to "decouple" the screen drawing from the game locking ?
4) Is the lock done with "dsb_lock()" equivalent to the implicit lock in "dsb_fullscreen()" ?
5) Also, sys_inventory_enter() etc. function are called after the inventory is entered, is it still possible to interrupt/override the inventory screen display ?
What Is Your Quest ?
- Gambit37
- Should eat more pies
- Posts: 13773
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Renderer questions and requests
I'm interested in #2 and #3 also -- I think a full screen, dynamic magic map would be pretty cool... 

Re: Renderer questions and requests
Parallax made a fullscreen magic map. I think it's dynamic.
Other question: I'm unhappy, I can't create a dsb_msgzone in a fullscreen bitmap. For some reason, the target I pass is invalid. Also, I don't understand what the third argument (number) is for:
DSB complains : dsb_msgzone target is invalid. I'm not even sure it's talking about the bitmap (sheet) or the instance (next_dialog)
Also, once a dsb_fullscreen is rendered without EXIT_ON_CLICK, what's the best way to make the game return to normal (ie. the dungeon view) ?
Other question: I'm unhappy, I can't create a dsb_msgzone in a fullscreen bitmap. For some reason, the target I pass is invalid. Also, I don't understand what the third argument (number) is for:
Code: Select all
dsb_msgzone(sheet, next_dialog, number, x, y, width, height, M_ACTIVATE)
Also, once a dsb_fullscreen is rendered without EXIT_ON_CLICK, what's the best way to make the game return to normal (ie. the dungeon view) ?
What Is Your Quest ?
Re: Renderer questions and requests
2) Have you tried dsb_add_condition, setting type to PARTY?
- Sophia
- Concise and Honest
- Posts: 4307
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Renderer questions and requests
The reason that character portraits must be passed to dsb_replace_portrait as a string is because there is no (easy and sane) way for me to directly save a reference to an arbitrary bitmap. This also means that any modifications you make to the character portrait bitmap aren't saved, so drawing on it is probably not going to work as well as you might hope, because saving and reloading will ruin anything you've done. If you really want to do this, the best approach might be to create a new bitmap in gfx, pass it to dsb_replace_portrait, and draw directly on it, but you'll have to write code in sys_game_load to ensure that the portraits are properly refreshed on every game reload.Joramun wrote:I couldn't find a function to return the character portrait (as a bitmap).
I find two uses to this:
- Make custom displays of character portraits
- Being able to make alterations to portraits without entirely replacing them with dsb_replace_portrait() using the draw functions
Yes, ian_scho had the right idea. Just make an overlay that covers up the entire viewport.Joramun wrote:Is there a way to override the viewport ? (without overriding the full screen)
Not really. The game is locked in dsb_fullscreen because an internal loop entirely separate from the game's main loop is running.Joramun wrote:Is the lock done with "dsb_lock()" equivalent to the implicit lock in "dsb_fullscreen()"
This means that:
I'd have to duplicate a lot of the "main loop" code inside of the "inner loop" of dsb_fullscreen. I'll figure out how easy or hard this is.Joramun wrote:I see the dsb_fullscreen locks the game. Is there any way to "decouple" the screen drawing from the game locking ?

It's possible to block it, with dsb_lock_game(LOCK_INVENTORY). If you want more precise control than this, let me know and I'll see if I can come up with something.Joramun wrote:Also, sys_inventory_enter() etc. function are called after the inventory is entered, is it still possible to interrupt/override the inventory screen display ?
The target is invalid because dsb_msgzone is expecting a subrenderer bitmap. I never thought that someone would try to use it in a full screen bitmap.Joramun wrote:I'm unhappy, I can't create a dsb_msgzone in a fullscreen bitmap. For some reason, the target I pass is invalid.

It's a zone number. This allows you to override/replace zones by specifying an existing handle. It also allows msgzones to have more information about where you clicked, because the zone number you clicked is passed as the msg's data parameter. If you don't care about any of this, just keep incrementing the number for every new zone.Joramun wrote:Also, I don't understand what the third argument (number) is for
Return true from any of the functions you pass it to drop back to the game.Joramun wrote:Also, once a dsb_fullscreen is rendered without EXIT_ON_CLICK, what's the best way to make the game return to normal (ie. the dungeon view) ?
Re: Renderer questions and requests

Also, Ian's Scho's idea is cool but is it possible to make said buttons and work on the bitmap that is passed to the dsb_condition() function ?
I guess than answer is the same than with a full screen overlay: yes but without dsb_msgzone()

EDIT: Ok, I've tried to create a button using dsb_fullscreen's click_func argument but it doesn't accept extra arguments aside from mouse parameters...
I think I'll have to create some complicated loop instead

EDIT 2: I still have problems with the local keyword it seems

Now I have a perfectly working, simply customizable DIALOG SYSTEM

What Is Your Quest ?
-
- Adept
- Posts: 221
- Joined: Sat Jan 07, 2006 1:54 am
- Location: Britain
- Sophia
- Concise and Honest
- Posts: 4307
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Renderer questions and requests
It's better this way, really. The main purpose of dsb_msgzone is to send a message to something based on where you click. This works fine for a subrenderer, because you send messages to the object instance that the subrenderer is associated with. For a full screen thing, though, you'd have to create some inst to receive the messages, and it gets a little weird.Joramun wrote:It means I'll have to create buttons on my bitmap with my own tiny Lua hands.
In that case, what you are really wanting to do is create clickzones over the viewport. This is obviously possible to do (as the engine does it all the time) but you can't dynamically create arbitrary ones. Would there be some use in being able to do so?Joramun wrote:Also, Ian's Scho's idea is cool but is it possible to make said buttons and work on the bitmap that is passed to the dsb_condition() function ?

-
- Adept
- Posts: 221
- Joined: Sat Jan 07, 2006 1:54 am
- Location: Britain
Re: Renderer questions and requests
It would probably have some uses in creating custom plot/dialogue screens, shops, taverns, and so on?
- Gambit37
- Should eat more pies
- Posts: 13773
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Renderer questions and requests
Yes, yes, yes, gimme some code, I need all the code, bwaaaaa ha ha ha ha bwap bwaaaaaghhh...
Re: Renderer questions and requests
Copy these into the corresponding files.
Obviously, it's not finished. It's just a simple example of what can be done with DSB in a few tens of minutes of coding.
dungeon.lua
objects.lua
startup.lua
Obviously, it's not finished. It's just a simple example of what can be done with DSB in a few tens of minutes of coding.
dungeon.lua
Code: Select all
---DSB ESB---
--[[ Autogenerated by ESB.
Trying to edit this file by hand may not give you
particularly good results.
]]
dsb_text2map(0, 32, 32, 100, 1, {
"10000000000000000000000000000000",
"10000000000000000000000000000000",
"11100000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"00000000000000000000000000000000"} )
dsb_level_wallset(0, wallset.default)
dsb_add_champion(1, "TEST_1", "port_mophus", "TEST_1", "", 9000, 9000, 9000, 2550, 2550, 2550, 2550, 2550, 2550, 500, 15, 15, 15, 15)
ch_exvar = {
}
dsb_spawnburst_begin(7)
dsb_spawn(1, "doorframe", 0, 0, 0, 4)
dsb_spawn(2, "door_black", 0, 0, 0, 4)
dsb_spawn(7, "dialog_reply", 0, 3, 0, 4)
dsb_spawn(4, "event_dialog", 0, 2, 1, 4)
dsb_spawn(5, "dialog_reply", 0, 3, 1, 0)
dsb_spawn(3, "trigger", 0, 2, 2, 4)
dsb_spawn(6, "event_dialog", 0, 4, 2, 4)
exvar = {
[3] = { target = 4,
msg = 100000,
opby_party = true },
[4] = { silent = true,
msg = 100000,
text = "TEST ONE/MOPHUS SPEAKING",
target = { 5, 7 } },
[5] = { target = 6,
text = "TEST TWO - I'M A BURGER",
msg = 100000,
silent = true },
[6] = { text = "DIALOG 2" },
[7] = { text = "TEST THREE - EXIT / VERY LONG TEXT BLA BLA BILBOBIL" },
}
dsb_spawnburst_end()
EDITOR_FLAGS = 255
dsb_champion_toparty(0, 1)
dsb_party_place(0, 0, 1, 2)
Code: Select all
obj.event_dialog = {
type="FLOORFLAT",
class="MECHANICS",
msg_handler=dialog_msg_handler,
esb_take_targets = true
}
obj.dialog_reply = {
type="FLOORFLAT",
class="MECHANICS",
esb_take_targets = true
}
Code: Select all
-- TEMP: Remove intro
function sys_game_intro()
return true
end
-- TEMP: Autoselect Enter
--function sys_game_start(savegames)
-- return nil
--end
function show_dialog(id,data)
if not exvar[id] then return
else
local options=exvar[id]
-----------------
-- Main bitmap --
-----------------
local sheet = dsb_new_bitmap(640, 480)
dsb_bitmap_clear(sheet, {0, 0, 150})
if options.sheet then
dsb_bitmap_draw(gfx[options.sheet], sheet, 0, 0, false)
end
local level, x, y, facing
level, x, y, facing = dsb_party_coords()
local x_size, y_size, light, xp_multiplier = dsb_level_getinfo(level)
local dview = dsb_dungeon_view(level, x, y, facing, light)
local y_text, x_text
x_text= 8
y_text= 8
if options.show_viewport==true then
dsb_bitmap_draw(dview, sheet, 0, 86, false)
end
--~ if options.show_party=true then
--~ for i=0,3
--~ local char = dsb_ppos_char(i)
--~ if (valid_and_alive(char)) then
--~ dsb_bitmap_draw(, sheet, 0, 0, false)
--~ else
--~ end
dsb_bitmap_rect(sheet, 450, 0, 639, 86, {240,240,40}, false)
if options.npc_portrait then
dsb_bitmap_draw(gfx[npc_portrait], sheet, 520, 12, false)
else
dsb_bitmap_draw(gfx["port_mophus"], sheet, 520, 12, false)
end
dsb_textformat(28, 12, 10)
--~ if (exvar[id] and exvar[id].text) then
--~ local lines, num_lines = dsb_linesplit(exvar[id].text, "/")
--~ local y_base = 72 - (num_lines*7) + (num_lines % 2)
--~ local i
--~
--~ for i=1,num_lines do
--~ dsb_bitmap_textout(sr, gfx.scroll_font, lines[i],
--~ 124, y_base+((i-1)*14), CENTER, scroll_color)
--~ end
--~ end
--~
local color = {240,240,240}
if options.color then color = options.color end
local text = "DIALOG"
if options.text then text = options.text end
local lines, num_lines = dsb_linesplit(text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
if y_text<=86 then y_text=86 end
dsb_bitmap_rect(sheet, 0, 0, 449, y_text, {240,240,40}, false)
y_text=y_text+5
local answer=0
clickzones={}
local target = options.target
if target then
local number = 0
if type(target)=="table" then
for k,el in pairs(target) do
if exvar[el] then
if exvar[el].text then
local lines, num_lines = dsb_linesplit(exvar[el].text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
--lines = dsb_bitmap_textout(sheet, sys_font, exvar[el].text, x_text, y_text, LEFT, {222,222,222})
dsb_bitmap_rect(sheet, 0, y_text-3-12*total_lines, 449, y_text, {240,240,40}, false)
local next_dialog = exvar[el].target
if next_dialog then
--dsb_msgzone(sheet, next_dialog, number, 0, y_text-3, 449, y_text+12*lines+2, M_ACTIVATE)
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, next_dialog }
else
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, nil }
end
y_text=y_text+5
end
end
end
else
if exvar[target] then
if exvar[target].text then
local lines, num_lines = dsb_linesplit(exvar[el].text, "/")
local total_lines=0
for i,t in pairs(lines) do
total_lines = total_lines + dsb_bitmap_textout(sheet, sys_font, t, x_text, y_text, LEFT, color)
y_text=y_text+12
end
dsb_bitmap_rect(sheet, 0, y_text-3-12*lines, 449, y_text+2, {240,240,240}, false)
local next_dialog = exvar[target].target
if next_dialog then
--dsb_msgzone(sheet, next_dialog, number, 0, y_text-3, 449, y_text+12*lines+2, M_ACTIVATE)
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, next_dialog }
else
answer=answer+1
clickzones[answer]={ 0, y_text-3-12*total_lines, 449, y_text+2, nil }
end
y_text=y_text+5
end
else
lines = dsb_bitmap_textout(sheet, sys_font, "...", x_text, y_text, LEFT, {222,222,222})
dsb_bitmap_rect(sheet, 0, y_text-3, 449, y_text+12*lines+2, {240,240,240}, false)
y_text=y_text+5
end
end
end
local bitmap_or_func, click_func, update_func, mouse, fade
if answer==0 then
click_func=EXIT_ON_CLICK
else
function click_func(mouse_x,mouse_y,mouse_button)
for k,el in pairs(clickzones) do
if mouse_x <= el[3] and mouse_x >= el[1] and mouse_y <= el[4] and mouse_y >= el[2] then
if el[5]==nil then
return true
else
dsb_msg(1, el[5], M_ACTIVATE, 0)
return true
end
end
end
return false
end
end
update_func=nil
mouse = true
--if options.no_mouse then mouse = false end
fade = false
if options.fade then fade = true end
dsb_fullscreen(sheet, click_func, update_func, mouse, fade)
end
end
dialog_msg_handler = {
[M_ACTIVATE] = show_dialog
--[M_DEACTIVATE] = object_disable,
--[M_TOGGLE] = object_toggle,
--[M_CLEANUP] = clean_up_target_exvars,
--[M_RESET] = trigger_reset,
--[M_DESTROY] = self_destruct
}
What Is Your Quest ?
Re: Renderer questions and requests
Try it instead of joking
. You might reconsider and continue all your project in DSB instead 


What Is Your Quest ?
Re: Renderer questions and requests
Ok. Let me look into RTSB and what I can do for RTC mechanics translation 
(besides, this tool badly needs to be cleaned of its dust)

(besides, this tool badly needs to be cleaned of its dust)
What Is Your Quest ?