Jump to content
Eternal Lands Official Forums
m_bee

More compact inventory

Recommended Posts

UPDATE: All the isues addressed: this patch does the following:

 

A: It provides a new compact inventory mode, switchable via an option in the misc tab

B: It shortens the numbers above 999 like 1.2k or so, this takes efffect in the inv, the trade window and the quickbar.

C: As a result of B, there was no way to know the exact amount of a stacked item when it was above 999, so I added this: a floating tip that shows the old format when you hover any item. This affects only the inventory and the trade window. I dont think that in the quickbar it is of any use.

 

This patch does not solve the wrapping issues, since ttlanhil suggested (and I am almost sure) that my code is not the responsible for that. If i can clean something in that other issue I will submit a sepparete patch for that.

 

Hi mates,

 

I never liked dthe fact that the inventory windodw breaks the layout uniformity, at least in 1024x768, the size I play, it is damn huge, and when you have inv, manu and storage open it is really a pain to be able to see the three windows completely, the chat on the top, and what you are writing on the bottom line. So, I made a patch to change this via de options -> Tab Misc -> Use a more compact inventory window. Here you can see both windows, along with the storage one, so you can compare.

 

Teh patch

 

805603.jpg

 

Nothing too complicated, I know, but I missed this possibility. The patch is done in a way that respects all the previous settings (it should, at least), meaning that I used the already existing

 

(video_mode>4?X:Y)

 

And rewrote them as

 

(video_mode>4&&!use_compact_inventory?X:Y)

 

So, this option has no effect when al the things that have no effect on lower resolutions, do have no effect. (I explained it weird, but reread it -lol-). To calculate a couple of realocations y use that also, so, there should be no problem in any mode or using the normal invenroty as ever. The default for that var is 0, so you need to activate this for it to take effect.

 

[b]Help request: if the inventory is open when I change this, it all messes up, because the window does not resize. That would be cool, but, if not possible, can anyone tell me how to close the inventory window in case it is opened, when you click the checkbox? May it be to activate or deactivate the compact inventory.
[/b]

Fixed. Look below.

 

Thanks for any info, any report/flame/suggestion is welcome. :)

Edited by m_bee

Share this post


Link to post
Share on other sites

Espect to have probles with items that have lots of descriptive text. You don't have enough space there for how much text you get with some items.

Share this post


Link to post
Share on other sites

I like the idea of this patch. I run in 1024x768 and I don't like the increased inventory window either.

 

I'll give the patch a whirl.

Share this post


Link to post
Share on other sites

options -> Tab Misc -> Use a more compact inventory window. Here you can see both windows, along with the storage one, so you can compare.

 

Help request: if the inventory is open when I change this, it all messes up, because the window does not resize. That would be cool, but, if not possible, can anyone tell me how to close the inventory window in case it is opened, when you click the checkbox? May it be to activate or deactivate the compact inventory.

i'd suggest that it's called "the compact window", since it simply uses the smaller one that's already available

as far as closing the window, you can close_window() (i think that's the command name)... you can get the variable for the window number near the top of the source file

 

Espect to have probles with items that have lots of descriptive text. You don't have enough space there for how much text you get with some items.

uhm
The patch is done in a way that respects all the previous settings (it should, at least), meaning that I used the already existing

unless it changes the font size or the re-wrap length when the resolution changes (and I'm pretty sure it doesn't) then it's fine.

in fact, the 800x600 version of the inventory window got more description space in the last update (the form that this option enables)

 

I like the idea of this patch. I run in 1024x768 and I don't like the increased inventory window either.

maybe at larger resolutions it makes more sence... maybe it should default to the larger version at 1260 or larger, but have the user able to toggle between the large/small ones?

Share this post


Link to post
Share on other sites

First of all, thanks for all the feedback, it is really apreciated. :P

 

This is my first attempt into the el client code, so it was more like a dirty hack. I have cleaned it a bit, and made sure that the old behaviour is not affected in any way by the new one (my main concern is to retain all the actual functionality).

 

Espect to have probles with items that have lots of descriptive text. You don't have enough space there for how much text you get with some items.

 

Actually I havent seen a problem, maybe there could be items that need a bigger space, but I dont think that is a problem. I can give space for another line or a couple of lines if needed. I dont have a so great inventory to try all the descriptions, but time will tell. As I say, I dont think that is the biggest of the problems, unless I am missing something obvious (the could perfectly be possible -lol-).

 

Help request: if the inventory is open when I change this, it all messes up, because the window does not resize. That would be cool, but, if not possible, can anyone tell me how to close the inventory window in case it is opened, when you click the checkbox? May it be to activate or deactivate the compact inventory.

i'd suggest that it's called "the compact window", since it simply uses the smaller one that's already available

as far as closing the window, you can close_window() (i think that's the command name)... you can get the variable for the window number near the top of the source file

Yes, it uses the smaller one with a slight variation wich I dont remember right now. So, you might be right in the nomenclature.

I will continue looking on closing the window, but I would like better to reload or readjust in in hot. I have been looking into items.c and widgets.c (and many other files) seeking for the info that I need to understand how it all works before doing idiotic things. So, Im still learning how the interface works. Thanks for the tip, it will surelly be usefull on my finding process. :(

 

I like the idea of this patch. I run in 1024x768 and I don't like the increased inventory window either.

maybe at larger resolutions it makes more sence... maybe it should default to the larger version at 1260 or larger, but have the user able to toggle between the large/small ones?

I think that the big window should be default for 1260 at least, but in 1024, the inventory window really takes sooooo much space. And i just could not stand it. If I manage to make a worthable patch (that is, if I manage to elegantly find a solution for the layout when the window is opened and I change the checkbox) then the patch will be complete and working ok (well, maybe I need more space for descriptions, but nothing more). I dont have time to develop really complex things since I have a lot of duties, but this thing is a thing that really I could not stand, so I decided to make my own solution. This was just a snippet of my idea. I also plan to add a way to avoid numbers overflow on the inv cells (since they are smaller now) and this seems to be on a right path, so, no tips needed here :)

 

By the way, there was also some persons interested in this idea on the spanish unofficial channel. So it seems that I am not the only one with this thought.

 

I will continue polishing it and will submit the definitive critter when it is done. If you like it, or you like some part of it, you are of course free to include it in the cvs if you wish or whatever. If not, well, I will use it for me, I find it very useful :)

Share this post


Link to post
Share on other sites

Nice work m_bee! One note, when posting screenshots with patches, make sure they are while you are on the test server. :P

Share this post


Link to post
Share on other sites
Espect to have probles with items that have lots of descriptive text. You don't have enough space there for how much text you get with some items.
Actually I havent seen a problem, maybe there could be items that need a bigger space, but I dont think that is a problem. I can give space for another line or a couple of lines if needed. I dont have a so great inventory to try all the descriptions, but time will tell. As I say, I dont think that is the biggest of the problems, unless I am missing something obvious (the could perfectly be possible -lol-).
if the only change to the space available is from going to the smaller layout, then ignore this issue. if there's a problem, it's not caused by your code (maybe mine, since I'm responsible for the inventory re-arrangement for the last update... but the room for description got larger then. as far as i could tell there is enough space)
I also plan to add a way to avoid numbers overflow on the inv cells (since they are smaller now) and this seems to be on a right path, so, no tips needed here :D
okay, but a suggestion: the trade window. if you can fix the quantity length issues in that as well it'd be handy :D

Share this post


Link to post
Share on other sites
I also plan to add a way to avoid numbers overflow on the inv cells (since they are smaller now) and this seems to be on a right path, so, no tips needed here ;)
okay, but a suggestion: the trade window. if you can fix the quantity length issues in that as well it'd be handy :P

It is done, and I will test this evening the code as much as I can and let you know whether it works or not. I have applied this to the inventory and to the quickbar. So, the trade window should be no problem (though I havent looked into its code). By the way, all the issues regarding the refresh of the window have been fixed as well. This is tEh code in item.c that fixed it:

 

/* Prototype added to prevent warnings on most compilers, I call
show_items_handler(window_info*) from display_items_handler(window_info*)
to redraw the window, so when I select/unselect the compact_inv_window
option, the window is redrawn properly */

int show_items_handler(window_info * win);

int display_items_handler(window_info *win)
{
Uint8 str[80];
int x,y,i;
int item_is_weared=0;
Uint32 _cur_time = SDL_GetTicks(); /* grab a snapshot of current time */

show_items_handler(win);
glEnable(GL_TEXTURE_2D);

 

As you see, just a call to the function to redraw the window from the one that redraws the items within. The prototype has been added above to prevent possible compilation issues on some compilers. So, the patch right now works flawlessly, and should not present any problem. I have updated the link above, it also includes the number layout patch, though I might need to work on it a bit more. I havent really tested that part.

 

By the way, ttlanhil, I wanted to ask you a favour. If you still maintain the windows cvs binary that you used to maintain, could you include this and the Drakos patch for the hud stat bars against the latest cvs and send me a copy of the binary for windows? I dont have access to a windows compiler (if I had I would compile this myself as I do in linux).

 

Sorry to bother you, If you are still maintaining it it would be easy, if not, then dont do the work just for me. I will find any other solution :(

 

Thanks for all your feedback :)

 

PS. I will update the link to the patch, in the first post, right now,.

Share this post


Link to post
Share on other sites
By the way, ttlanhil, I wanted to ask you a favour. If you still maintain the windows cvs binary that you used to maintain, could you include this and the Drakos patch for the hud stat bars against the latest cvs and send me a copy of the binary for windows? I dont have access to a windows compiler (if I had I would compile this myself as I do in linux).
I do, though I don't update it that often. I'll build a client with those and other patches for people to test, and let you know when it's done

Share this post


Link to post
Share on other sites

this part:

-	draw_string_small(4, win->len_y - (video_mode>4?85:105), items_string, 4);
+	// Moded
+	if(compact_inv_window){
+	snprintf(str,sizeof(items_string),"%i %s",item_list[i].quantity, items_string);
+	draw_string_small(4, win->len_y - (video_mode>4?85:105), str, 4);
+	}
+	else draw_string_small(4, win->len_y - (video_mode>4?85:105), items_string, 4);

seems bugged. i is 44, since that's the last slot (not the slot that's eye-clicked)

it also displays the number even if there isn't one. so you'll see a 0 in the inv description area

I've removed this bit of the patch from the version I'll send you

Share this post


Link to post
Share on other sites

this part:

-	draw_string_small(4, win->len_y - (video_mode>4?85:105), items_string, 4);
+	// Moded
+	if(compact_inv_window){
+	snprintf(str,sizeof(items_string),"%i %s",item_list[i].quantity, items_string);
+	draw_string_small(4, win->len_y - (video_mode>4?85:105), str, 4);
+	}
+	else draw_string_small(4, win->len_y - (video_mode>4?85:105), items_string, 4);

seems bugged. i is 44, since that's the last slot (not the slot that's eye-clicked)

it also displays the number even if there isn't one. so you'll see a 0 in the inv description area

I've removed this bit of the patch from the version I'll send you

Yes, I know about that, thanks though for spotting it and refreshing my mind. I had forgotten bout it. I try to show the number there, because when I activate the thing to show the abreviations for numbers, that would be a way to get an exact count of the quantity on a stack. But since that was not a priority I just forgot about it. I will fix that to make it show the number of items in a stack.

 

Also thanks for your help on building a client for windows. Let me know when it is done. You are so kind ttlanhil. It seems that this patch is not directly compatible with the statbars one, I had to patch it by hand.

 

Thanks ;)

Share this post


Link to post
Share on other sites

807009.jpg

 

Any clue on where should I look?

 

The small inventory is what causes the line wrapping, but the weird thing is in the manu window...

Share this post


Link to post
Share on other sites

Any clue on where should I look?

 

The small inventory is what causes the line wrapping, but the weird thing is in the manu window...

if you do something about this, please post it as a seperate patch to berlios, it's quite an old bug

if you want to look into it, check where the text comes from and back-track until you find where it's line-wrapped (apparently twice)

Share this post


Link to post
Share on other sites

The problem with that text is that all the windows that can show that text use the same buffer for the message, and different width windows fold the text differently. In that screen shot, it probably added returns for the manu window first, then for the inventory window. You almost need a seperate text buffer for each window if different window sizes will be used combined with only wrapping it once.

Share this post


Link to post
Share on other sites

The problem with that text is that all the windows that can show that text use the same buffer for the message, and different width windows fold the text differently. In that screen shot, it probably added returns for the manu window first, then for the inventory window. You almost need a seperate text buffer for each window if different window sizes will be used combined with only wrapping it once.

I will look deeper into this when I have time. If I find something definitive then I will make another patch. I

Thanks to both of you for the input.

Share this post


Link to post
Share on other sites

I have been thinking (not that I do too often, but sometimes... :D ) and I think that I have found the better way to archieve the abreviation of the inv numbers, that is a must when using the reduces layout. I dont think this needs any explanation:

 

			if(compact_inv_window||video_mode<=4) {
				// Moded
				if(item_list[i].quantity<1000){
				snprintf(str,sizeof(str),"%d",item_list[i].quantity);
				}
				else if(item_list[i].quantity<10000){
				snprintf(str,sizeof(str),"%1.1fk",((float)item_list[i].quantity)/1000);
				}
				else if(item_list[i].quantity<100000){
				snprintf(str,sizeof(str),"%.0fk",((float)item_list[i].quantity)/1000);
				}
				else if(item_list[i].quantity<1000000){
				snprintf(str,sizeof(str),"%.0fk",((float)item_list[i].quantity)/1000);
				}
				else {
				snprintf(str,sizeof(str),"%.0fm",((float)item_list[i].quantity)/1000000);
				}

This is the formatting code, it works, and does ok. But there is no way to know exactly how much you have into a stack if the number is above 999, I tried many things to sove this, but suddenly I opened my storage and saw the help tips. That is the key, i thought, and came with this into mouseover_items_handler()

 

		if(item_list[pos].quantity){
			snprintf(quantity_edit_str, sizeof(quantity_edit_str), "%i", item_list[pos].quantity);
			show_help(quantity_edit_str, mx, my);
		}

 

It works nicely, if it weren't because it draws the tip with the quantity UNDER the window (I can see thru the window the tip label seeking my mouse pointer).

 

Any ideas? I think that for today my brain does not work anymore...

Edited by m_bee

Share this post


Link to post
Share on other sites

		if(item_list[pos].quantity){
			snprintf(quantity_edit_str, sizeof(quantity_edit_str), "%i", item_list[pos].quantity);
			show_help(quantity_edit_str, mx, my);
		}

 

It works nicely, if it weren't because it draws the tip with the quantity UNDER the window (I can see thru the window the tip label seeking my mouse pointer).

 

Any ideas? I think that for today my brain does not work anymore...

you'll probably have to do it in display_items_handler() instead. probably near the end of that function, so that it's drawn last.

Share this post


Link to post
Share on other sites

UPDATE: All the isues addressed: this patch does the following:

 

A: It provides a new compact inventory mode, switchable via an option in the misc tab

B: It shortens the numbers above 999 like 1.2k or so, this takes efffect in the inv, the trade window and the quickbar.

C: As a result of B, there was no way to know the exact amount of a stacked item when it was above 999, so I added this: a floating tip that shows the old format when you hover any item. This affects only the inventory and the trade window. I dont think that in the quickbar it is of any use.

 

This patch does not solve the wrapping issues, since ttlanhil suggested (and I am almost sure) that my code is not the responsible for that. If i can clean something in that other issue I will submit a sepparete patch for that.

Share this post


Link to post
Share on other sites

Can you make the floating quantities only appear when the quantity has been shortened?

 

Compile warnings:

items.c: In function `display_items_handler':
items.c:496: warning: ISO C90 forbids mixed declarations and code
items.c:508: warning: ISO C90 forbids mixed declarations and code

trade.c: In function `display_trade_handler':
trade.c:113: warning: ISO C90 forbids mixed declarations and code
trade.c:121: warning: ISO C90 forbids mixed declarations and code

and please, indent your code.

Share this post


Link to post
Share on other sites

Can you make the floating quantities only appear when the quantity has been shortened?

Sure, it is done. I am amazed that I did not think of it before, thanks!

I will diff it agains the latest cvs, which is was not yesterday, and resend it in about 5-10 minutes.

 

Compile warnings:

items.c: In function `display_items_handler':
items.c:496: warning: ISO C90 forbids mixed declarations and code
items.c:508: warning: ISO C90 forbids mixed declarations and code

trade.c: In function `display_trade_handler':
trade.c:113: warning: ISO C90 forbids mixed declarations and code
trade.c:121: warning: ISO C90 forbids mixed declarations and code

and please, indent your code.

Oh, I usually dont do these weird things, but i was been up for about +50 hours and wanted to go to bed lol. Sorry for that and thanks for the reminder. It will not happen anymore :)

 

Thanks all for your input. It is really really appreciated. It is my very first attempt at the elc code and it was a bit hard :icon13:

Edited by m_bee

Share this post


Link to post
Share on other sites

By the way, i havent tried with really big quantities, since my inventory is not too big and I have not a big storage either, so, if you detect any problem with bigger quantities just let me know :)

Share this post


Link to post
Share on other sites

yeah I want smaller inventory window too!

 

a toggle checkbox in options for example could to - to select whether I want a bigger or smaller one.

Share this post


Link to post
Share on other sites

yeah I want smaller inventory window too!

 

a toggle checkbox in options for example could to - to select whether I want a bigger or smaller one.

That is the way it is done (look the option in the picture I posted). If the inv is open when you change this checkbox it automatically resizes and the layout is reordered.

Share this post


Link to post
Share on other sites

/* Prototype added to prevent warnings on most compilers, I call
show_items_handler(window_info*) from display_items_handler(window_info*)
to redraw the window, so when I select/unselect the compact_inv_window
option, the window is redrawn properly */

 

Wouldn't it be easier to do it like this (in elconfig.c)?

void change_compact_inv(int *var)
{
change_var(var);
if(get_show_window(items_win)) {
	show_window(items_win);
}
}
<snip>
add_var(BOOL,"compact_inv_window","uci",&compact_inv_window, change_compact_win, 1, "Compact inventory window", "Use a more compact inventory window",MISC);

Share this post


Link to post
Share on other sites

/* Prototype added to prevent warnings on most compilers, I call
show_items_handler(window_info*) from display_items_handler(window_info*)
to redraw the window, so when I select/unselect the compact_inv_window
option, the window is redrawn properly */

 

Wouldn't it be easier to do it like this (in elconfig.c)?

void change_compact_inv(int *var)
{
change_var(var);
if(get_show_window(items_win)) {
	show_window(items_win);
}
}
<snip>
add_var(BOOL,"compact_inv_window","uci",&compact_inv_window, change_compact_win, 1, "Compact inventory window", "Use a more compact inventory window",MISC);

Surely yes :hug: and also much more efficient and clean. Though I dont know still too well the source, so I just figured the other way sooner. I will look into this and try to do it this way. I like it better. Thanks. :hug:

 

I was also wrong about the quickbar, after testing it a bit, I now think that the tips there are also useful. So I added that to the patch and submited it to berlios.

 

EDIT: I did it that way, the window, for any reason only resizes itself in the y axis, and not the x one. Seems that the objects are not redistributed either... So, for now I will leave it that way. I will, though, continue studying the subject and try to do it your way. I think it is better.

Edited by m_bee

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×