The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

do_look

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Coding
View previous topic :: View next topic  
Author Message
Marcelus



Joined: 06 Jun 2009
Posts: 2

PostPosted: Sat Jun 06, 2009 6:01 am    Post subject: do_look Reply with quote

I was wondering how would I go about changing the way do_look format things.

Currently it is:

Description of the room

[Exits]

Items

Mobs

Map



I would like it to be:

Map Description of the Room

Exits

Items

Mobs


I have looked over the code, I can easily move things up and down, but I cant for the life of me figure out how to make it so that the room description is next to the map display.

Thanks for any help,
Marcelus


Back to top
View user's profile Send private message
Kalahn
Codebase Developer


Joined: 18 Jan 2003
Posts: 710
Location: New Zealand

PostPosted: Tue Jun 09, 2009 8:00 pm    Post subject: Reply with quote

It isn't exactly easy, but reasonably straight forward if you have an okay understanding of what you are doing...

The map is rendered by do_map() as a number of lines of text sent to the player... by the time the code has returned from the do_map function the text has already been queued for sending out to the player.

What you are asking for is the ability to have a custom piece of text (the room description) appended to the top line of the map output.

In short the way I would tackle this, as follows:
rename "do_map()" to render_map_for_player().

At the same time provide a variable name for the second argument of new render_map_for_player() function:

i.e. change the do_map() function from:
Code:
void do_map(char_data *ch, char *)
to:
Code:
void render_map_for_player(char_data *ch, char *text_to_append_to_top_line)


Now create a redirecting do_map() function to replace the old function (which no longer exists)... this will just redirect to render_map_for_player() with an empty parameter... e.g:
Code:
void do_map(char_data *ch, char *)
{
    render_map_for_player(ch, "");
}


Now change the code in render_map_for_player() so the text_to_append_to_top_line argument is appended to the first line of the map.

Probably the easiest way to do this is replace the 2 lines which read:
Code:
ch->printlnf("  %s`x",outline);

with something like:
Code:

if(line==scan_miny){
  ch->printlnf("  %s %s`x",outline,text_to_append_to_top_line);
}else{
  ch->printlnf("  %s`x",outline);
}


Add a prototype for render_map_for_player() to prototyp.h so you can call render_map_for_player() from outside of map.cpp.

Lastly change do_look() so it calls render_map_for_player() with the room description as the second argument instead of do_map(ch,"");
e.g.
Code:
render_map_for_player(ch, FORMATF( "`=B%s`x", mxp_create_tag(ch, "RName", ch->in_room->name)));

Hope this helps,
-Kal



_________________
Kalahn
Developer of the Dawn of Time Codebase
http://www.dawnoftime.org/
Back to top
View user's profile Send private message Visit poster's website
Marcelus



Joined: 06 Jun 2009
Posts: 2

PostPosted: Thu Jun 11, 2009 5:49 am    Post subject: Reply with quote

How can I get it to auto justify the room description?

Ie I am getting this

C This is a street made of crushed grey stone, just to the south of a large square. A spiral staircase leads downwards to a dark cellar emanating a pungent odour. You can travel north to the square, or south along the roadway.
|
|
C-C-C
|
C

I would like for it to look like this:

C This is a street made of crushed grey stone, just to the
| south of a large square. A spiral staircase leads downwards
| to a dark cellar emanating a pungent odour. You can travel
C-C-C north to the square, or south along the roadway
|
|
C


Back to top
View user's profile Send private message
Kalahn
Codebase Developer


Joined: 18 Jan 2003
Posts: 710
Location: New Zealand

PostPosted: Thu Jun 11, 2009 1:43 pm    Post subject: Reply with quote

You are talking about a multiline room description, not the room name.

This is another step above what you were originally suggesting and isn't exactly trival.

You would need to prewrap the room description text, using something like
note_format_string_width(original_room_description, X, true, false);
Where X is the width you want it to wrap...
(This is assuming you wanted it wrapped to a different width than it typically is)

You could go for a fixed value for X or make it dynamic depending on the width of the text. something LIKE (i.e. untested - use wrapped_description_width in place of X above)
Code:
int wrapped_description_width=75; // a starting point
int map_width;
if (HAS_CONFIG2(ch,CONFIG2_NOMAPEXITS)){
  map_width=(scan_maxx-scan_minx)+2;
}else{
  map_width=(scan_maxx-scan_minx)*2+2;
}
wrapped_description_width=-= map_width;
char *new_text=note_format_string_width(original_room_description, X, true, false);


Now what you have to do is "stitch" the map and the description together.

The number_lines() function in string.cpp kind of does part of you want using getline(). Look at that and see if you can figure it out.

- Kal


Back to top
View user's profile Send private message Visit poster's website
Br0k30n3



Joined: 30 Dec 2013
Posts: 15

PostPosted: Wed Jan 01, 2014 4:57 pm    Post subject: Reply with quote



You mean something like this ? We were working on something like this a long time ago. Picture above was not it that is just a quick mock up with PSP.

I'll try to get a hold of Astin/Zyrian to see if he has an old copy of ED saved somewhere.

Been almost 10 years since I have had my nose in the code but it will come as I warm up.

::EDIT::

Just noticed that the last post was in 2009


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Coding All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin