The International Simutrans Forum

Development => Extension Requests => Topic started by: BBGunn on May 21, 2014, 02:06:01 AM

Title: List of available vehicles (without building depot)
Post by: BBGunn on May 21, 2014, 02:06:01 AM
Forgive me if this has been requested before; I couldn't find any relative recent threads.

The extension I want the most right now is a list of all the available vehicles in the game (era dependent). 

For example, imagine that I have a line of road convoys, and I want to upgrade it to trains.  But I want to make sure that my company can afford any of the available trains.  Currently, to look at all available trains, I have to build one piece of railroad, then build a depot, then click on the depot to bring up a list of available vehicles.  But wouldn't it be better to have a list of all available vehicles somewhere that I can look at, without having to build a depot?  That way, I could save that money for later.  If I decide not to buy trains because they are too expensive, the money I spent just building a depot is wasted.
Title: Re: List of available vehicles (without building depot)
Post by: Yona-TYT on May 21, 2014, 03:06:20 AM

Having a list of the vehicles available at the time of the game can be very useful.
however, long ago I suggested this and no one bothered to create a patch.


do not know if things will be different this time.


http://forum.simutrans.com/index.php?topic=10184.msg96720#msg96720
Title: Re: List of available vehicles (without building depot)
Post by: BBGunn on May 21, 2014, 05:18:26 AM
Having a list of the vehicles available at the time of the game can be very useful.
however, long ago I suggested this and no one bothered to create a patch.


do not know if things will be different this time.


http://forum.simutrans.com/index.php?topic=10184.msg96720#msg96720
Ah, I missed that thread.  Thank you, Yona-TYT.  Yeah, from that thread, it looks like this sort of thing is not as easy to implement as it sounds. 
Title: Re: List of available vehicles (without building depot)
Post by: Yona-TYT on May 21, 2014, 06:37:10 AM
Ah, I missed that thread.  Thank you, Yona-TYT.  Yeah, from that thread, it looks like this sort of thing is not as easy to implement as it sounds. 



I'm afraid so.


But it's worth trying again, maybe someone can think of creating a good patch this time it.  ;)

Title: Re: List of available vehicles (without building depot)
Post by: prissi on May 21, 2014, 09:39:37 PM
It is extremely easy to implement, it will take me about one evening. But it is a great way to start understanding simutrans. So I had my hope up that someone would be bothered enough to do this.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on May 28, 2014, 09:27:10 PM
If you would give me some advises, I would like to give it a try.  :)
I have never really programmed before, only some programs on my calculator. But I have read articles about C++ and feel like I kind of understand how it works. I even had downloaded VS2010 on my old computer, read and even understood some pieces of the sourcecode, then compiled a working Simutrans. Small things for you guys, but big as a mountain for me! :)

So how would you suggest I get started?
Title: Re: List of available vehicles (without building depot)
Post by: Ters on May 28, 2014, 10:35:19 PM
feel like I kind of understand how it works.

I think that's about as far most C++ programmers get. But the only way to find out if you can swim is to get into the water. Simutrans is somewhat "deep water", at least in certain parts. I don't think the GUI is the deepest part (in terms of technical details of C++ or computers in general), but I haven't really "been there" myself.
Title: Re: List of available vehicles (without building depot)
Post by: Yona-TYT on May 28, 2014, 11:46:33 PM
I'm glad there is some interest in this. :thumbsup:
Title: Re: List of available vehicles (without building depot)
Post by: Aquin on May 29, 2014, 11:34:37 AM
Well there is the Dat-Viewer and Editor by Zeno http://sourceforge.net/projects/st-mass-dat/ (http://sourceforge.net/projects/st-mass-dat/) it can list all vehicles if you have the source .dat files.

Since it cannot save the list to any text or spreadsheet format, I added a little to it, now it saves the table as a tab delimeted text file to d:\summary.txt. http://simutrans-germany.com/files/upload/MassDatEditor.zip (http://simutrans-germany.com/files/upload/MassDatEditor.zip)
It should be fine with both Standart and Experimental .dat-files.
Title: Re: List of available vehicles (without building depot)
Post by: Ters on May 29, 2014, 04:26:17 PM
Well there is the Dat-Viewer and Editor by Zeno http://sourceforge.net/projects/st-mass-dat/ (http://sourceforge.net/projects/st-mass-dat/) it can list all vehicles if you have the source .dat files.

Since it cannot save the list to any text or spreadsheet format, I added a little to it, now it saves the table as a tab delimeted text file to d:\summary.txt. http://simutrans-germany.com/files/upload/MassDatEditor.zip (http://simutrans-germany.com/files/upload/MassDatEditor.zip)
It should be fine with both Standart and Experimental .dat-files.

Most players don't have the dat files, so they would need something that can read the pak files. However, the request is for an in-game solution, not a separate program.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on May 29, 2014, 08:44:06 PM
First step, I suppose, is to get a working simutranscompilations.
However, I get some fatal errors when Im compiling the trunk Simutrans on my new computer windows 7, 64 bits. I did not have these problems before on Windows Vista 32 bit.

I have followed the checklist in this thread http://forum.simutrans.com/index.php?topic=652.0 (http://forum.simutrans.com/index.php?topic=652.0) which worked on my old computer.

When I choose the w64 folder (after adding the libraries that should be added), I get these errors:
Code: [Select]
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_init
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_destroy
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_unlock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_lock
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_destroy
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_wait
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_broadcast
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_create
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_setdetachstate
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_wait
1>image_reader.obj : error LNK2001: unresolved external symbol _adler32@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzeof@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzread@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzerror@8
1>loadsave.obj : error LNK2001: unresolved external symbol _gzwrite@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzclose@4
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_join
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_destroy
1>loadsave.obj : error LNK2001: unresolved external symbol _gzgets@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzopen@8
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_post
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_init
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_wait
1>F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans\simutrans\trunk\Release\Simutrans.exe : fatal error LNK1120: 26 unresolved externals

Using the w32-folder i get these errors:
Code: [Select]
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_init
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_destroy
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_unlock
1>simgraph16.obj : error LNK2001: unresolved external symbol __imp__pthread_mutex_lock
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_destroy
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_wait
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_broadcast
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_create
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_setdetachstate
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_attr_init
1>simview.obj : error LNK2001: unresolved external symbol __imp__pthread_cond_wait
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_join
1>loadsave.obj : error LNK2001: unresolved external symbol __imp__pthread_barrier_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_post
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_init
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_destroy
1>simworld.obj : error LNK2001: unresolved external symbol __imp__sem_wait

There is a file called pthread.h in the "shared include" folder (according to the "how to compile.."-thread)
I have tried to install everything over again, but have not worked yet. What am I doing wrong?

---------------------------

Now I managed to get it down to these errors:


compiled using libraries for w64:
Code: [Select]
1>image_reader.obj : error LNK2001: unresolved external symbol _adler32@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzeof@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzread@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzerror@8
1>loadsave.obj : error LNK2001: unresolved external symbol _gzwrite@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzclose@4
1>loadsave.obj : error LNK2001: unresolved external symbol _gzgets@12
1>loadsave.obj : error LNK2001: unresolved external symbol _gzopen@8
1>F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans\simutrans\trunk\Release\Simutrans.exe : fatal error LNK1120: 8 unresolved externals

Managed to only get one error while compiling using libraries for w32:
Code: [Select]
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corruptThe reason I try with both libraries is that I frankly dont know which one to use  :o

How should I resolve these errors?

------------------------------

Im really really sorry about trippleposting, but: Yay! I got it working! 8)
I uninstalled Net framework 4.5, and download and installed Net framework 4.0.


So, with a working compilation, how would you coders out there suggest me to look for?
Title: Re: List of available vehicles (without building depot)
Post by: Ves on June 02, 2014, 08:49:03 PM
Well, after looking through the code, I found that maybe copying the files citylist_frame_t.cc and citylist_frame_t.h, renaming them to vehiclelist_frame_t.cc and /.h would do as a start. I did and managed then to create a new magic list entry and I have now a new window titulated "vehicle list" fully working in simutrans with its own icon! :D
Now I have to replace what's inside the window with something with vehicles.

What would be most desired? A "depot like" window or something else? I see fore me that you can use tabs to select the types of vehicles, where do I find the use of the icons used in the line management window? then something to differentiate between powered/unpowered and maybe even what kind of power..
Title: Re: List of available vehicles (without building depot)
Post by: An_dz on June 02, 2014, 09:52:35 PM
halt_info.cc have the icons you want, just check it.

If you use the same idea of the depot window it will be faster. Using the image_list components to draw them, the filtering functions and the the tabs structure, all you have to do is reload when you change vehicle type tab. Something like tabs inside tabs.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on June 02, 2014, 11:18:40 PM
Ok, thank you! I'm having problem stripping the old city-content out of the window I get many errors every time I try to remove something (sortings etc). What is the basic classes that is needed in order to make a clean window usable?
Title: Re: List of available vehicles (without building depot)
Post by: An_dz on June 03, 2014, 02:30:41 AM
The bare minimum is define /display/simgraph.h/ for the drawing stuff in the cc file.
/gui/gui_frame.h/ is required in the header file for the sizing stuff (D_MARGIN_LEFT, LINESPACE, etc.)
Title: Re: List of available vehicles (without building depot)
Post by: prissi on June 04, 2014, 09:57:16 PM
The proper way to make this is to generate a new list which just uses. I.e. derive from gui_scrolled_list.h
Code: [Select]
/**
* Container for list entries - consisting of text and color
*/
class scrollitem_t {
public:
virtual ~scrollitem_t() {}
virtual scr_coord_val get_h() const = 0; // largest object in this list
virtual scr_coord_val draw( scr_coord pos, scr_coord_val width, bool is_selected, bool has_focus ) = 0;
virtual char const* get_text() const = 0;
virtual bool is_valid() { return true; } //  can be used to indicate invalid entries
virtual bool is_editable() { return false; }
virtual bool sort( vector_tpl<scrollitem_t *> &, int, void * ) const { return false; } // not sorted, leave vector as before
};
An object for each vehicle. That way you could use a scrolled list and do not worry at all about scrollbars etc. Then you just add this list to a window.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on June 05, 2014, 06:35:25 AM
Up until now I have tried to get rid of the current content of the window (former citylist), but have failed badly.
What I have currently is this:

vehiclelist_frame_t
vehiclelist_stats_t

These classes are currently identicall as their citylists-correspondings, however I try to 'empty' them.

As how to make a structure, would you suggest that I keep and use the 4 files (vehiclelist_stats.cc /.h and vehiclelist_frame.cc /.h) with their classes?

I will experiement with the gui_scrolled_list.h when I come home tonight!
Title: Re: List of available vehicles (without building depot)
Post by: DrSuperGood on June 06, 2014, 03:40:52 AM
I would also be very grateful for a convoy type list. Especially for knowing what vehicles are coming in the future I often find myself going off and creating a dummy game just to see when vehicles come into production.

A useful feature for the window would be a speed approximation or load simulation for engines. Currently the only way to tell if an engine will meet your shipping requirements is to build a convoy with it in a depot (and probably sell it if it fails) or rely on past experience (you made one before and know what to expect). Experimental sort of has this listing a high and low speed tonnage weighting in the depots but being able to get the exact pull tonnage for a certain speed or determine the speed for a certain pull tonnage would be very useful and seems the sort of feature you would want in a vehicle list window.
Title: Re: List of available vehicles (without building depot)
Post by: Ters on June 06, 2014, 05:45:11 AM
Something like this tool?
Title: Re: List of available vehicles (without building depot)
Post by: DrSuperGood on June 06, 2014, 03:29:23 PM
Quote
Something like this tool?
Yes something like that looks like the sort of thing that needs to be built into the game rather than run as an external Java application. Especially since the mathematics governing train speeds and weights is not something most people can do in their heads.
Title: Re: List of available vehicles (without building depot)
Post by: Ters on June 06, 2014, 03:53:07 PM
The problem is that the UI for feeding the calculations of all these things is rather complicated. I'm not sure the GUI framework in Simutrans is up to it. An added bonus is that I can run this application on one monitor, and Simutrans on the other. (For me as a developer, I can even add new features or tweak existing ones without having to close and restart Simutrans. I also would never have made this without the ease at which I can develop and debug in Java compared to C++.) The drawback is that I have to keep the code in sync with Simutrans.
Title: Re: List of available vehicles (without building depot)
Post by: DrSuperGood on June 06, 2014, 10:07:14 PM
Quote
The problem is that the UI for feeding the calculations of all these things is rather complicated. I'm not sure the GUI framework in Simutrans is up to it.
I think that stems from the render engine used which is fully software based and so has to render everything from the UI to the simulation graphics in a pretty efficient and tightly optimized way so having each element act independently is quite difficult. However even if the UI was not so complicated I imagine something possible that works on a engine by engine basis that uses the value selection fields like the goods list does for speed (and other things in experimental but that seems broken?).

Maybe if Simutrans is operating in windowed mode each pop-up could me made a separate physical window (similar to how the 16 bit simtower did it)? Since modern OS like Windows (and Linux with the write windows manager) hardware accelerate windows this would be pretty useful as not only could you arrange windows accros multiple displays but it would also defer the windows management complexity from the game and its render engine.
Title: Re: List of available vehicles (without building depot)
Post by: Ters on June 06, 2014, 10:52:25 PM
I think that stems from the render engine used which is fully software based

Not really. It has nothing to do with rendering, but with how the GUI is tied to the underlying data and how events work. In a way, it has more to do with Simutrans' GUI being written in C++, rather than some managed language.

Maybe if Simutrans is operating in windowed mode each pop-up could me made a separate physical window (similar to how the 16 bit simtower did it)? Since modern OS like Windows (and Linux with the write windows manager) hardware accelerate windows this would be pretty useful as not only could you arrange windows accros multiple displays but it would also defer the windows management complexity from the game and its render engine.

Personally, I don't like such a GIMP-like setup. (GIMP has lately become configurable in that regard.) I feel my desktop becomes an unorganized mess. I can't just move all of Simutrans to my secondary monitor in one go (Shift+Win+Arrow) when I can let it run alone for a short while while I do something else. But window management has nothing to do with why I won't even contemplate porting my Java application into Simutrans.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on June 07, 2014, 12:09:57 AM
I am still stuck. I find myself realizing that I have very little knowledge of this. I have tried to get a clean window to work with, and came as far as only getting one error, but resolving that just creates two new, resolving them creates even more and so on. Tips to create a clean window are most welcome!

Then I wonder, I am supposed to take the vehicle information from somewhere. Should I use vehikel_besch_t or should I look after the information somewhere else?
I suppose that I should keep the _stats -files to gather and organize lists in there?
Title: Re: List of available vehicles (without building depot)
Post by: Ters on June 07, 2014, 08:16:48 AM
Should I use vehikel_besch_t or should I look after the information somewhere else?

vehikel_besch_t is the structure containing information about vehicle types (as opposed to individual actual vehicles), so yes, that should be the thing to use.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on June 12, 2014, 11:47:56 AM
Slowly I get forward, understanding more and more of what is what. I have found other parts that uses the gui_scrolled_list_t and copied it into my parts and it seems that that part is working. However, when I compile I get the error c2512 no appropriate default constructor available for gui_scrolled_list_t::const_text_scrollitem_t and for my own new class: vehiclelist_stats_t


I try to read about it on the net, but I come to short. What should I look for in order to resolve this?
Title: Re: List of available vehicles (without building depot)
Post by: prissi on June 12, 2014, 09:28:18 PM
At some point you are doing a copy or generating an array of stuff. For this first an emtpy element needs to be created, i.e. when you write
scrollitem_t t;

But there are only constructors with text_scrollitem_t( const char *, COLORVAL ), then you get this message.
Title: List of available vehicles (without building depot)
Post by: Ves on October 22, 2014, 11:03:17 PM
Hello dusty Computer!  ;D
I lost my internet connection for several months and also I was away, so no chance of dooing anything usefull. :redx:
But now its back! (the internet) 8)

I already pulled my hair off once, just to let it grow out during the summer and now pulled it half off again!
I completely ended up in a mess with classes and referenses and every error fixed, created 3 more errors! Therefore, I have now torn it all down to a fresh start, this time only working with a class called vehiclelist_frame_t and then skipped the vehiclelist_stats_t.

What I *think* I am suposed to do:
* create and define this vehiclelist_frame_t class and make it work as a window - done and tested with succesfull build and a new window in Simutrans!
* Call all the vehicles, so that I can use them, I suppose this is the method to use(?):
Code: [Select]
private
static vector_tpl<const vehikel_besch_t *> vehicles;

public
static vector_tpl<vehikel_besch_t const*> const& get_all_besch() { return vehicles; }
At least there are no red lines underneath! And I found some "Baum"-code that kind of did the same.....

* learn how to use the scrolled list.......
When looking in the code, I find many different ways of dooing lists. Eg the curiosity_edit_t looks one way, the baum_edit_t looks similar, yet different, the goods_frame_t have again another kind of using the code not speaking about the citylists. Maybe Im just plain dumb, but when I try to implement one way, I always get behind an obstructle I cant pass. The template you showed in this thread prissi, I have yet to figure out how to use it...

What I have done in the .cc-file so far, I made something that 'fills the list'. So far my logic brain tells me, this is where all the entries to the list is created and beeing 'filled' to the list (im not wrong here?). This peace of code looked similar in most places, and I managed to adapt it to my needs:

Code: [Select]
void vehiclelist_frame_t::fill_list(bool translate)
{
vehicles.clear();
FOR(vector_tpl<vehikel_besch_t const*>, const i, vehiclelist_frame_t::get_all_besch()) {
if (i) {
vehicles.insert_ordered(i, sort_mode);
}
}
// now build scrolled list
scl.clear_elements();
scl.set_selection(-1);
FOR(vector_tpl<vehikel_besch_t const*>, const i, vehicles) {
char const* const name = translate ? translator::translate(i->get_name()) : i->get_name();
scl.append_element(new gui_scrolled_list_t::const_text_scrollitem_t("vehicle list", COL_BLACK));
if (i == besch) {
scl.set_selection(scl.get_count() - 1);
}
}
}
Under these lines there are also no red underlines!

That peace of code demanded a "sort_mode", so I had to make a compare-section, it currently looks like this:
Code: [Select]
bool vehiclelist_frame_t::compare(gui_scrolled_list_t::scrollitem_t *aa, gui_scrolled_list_t::scrollitem_t *bb)
{
// if there is a mixed list, then this will lead to crashes!
vehikel_besch_t *a = (vehikel_besch_t *)aa;
vehikel_besch_t *b = (vehikel_besch_t *)bb;
switch (sort_mode) {
case 0: // default
break;
case 1:
return (a->get_topspeed(), b->get_topspeed()) < 0;
case 2:
return (a->get_ware() - b->get_ware()) < 0;
case 3:
return (a->get_zuladung() - b->get_zuladung()) < 0;
case 4:
return (a->get_intro_year_month() - b->get_intro_year_month()) < 0;
case 5:
return (a->get_preis() - b->get_preis()) < 0;
default: break;
// default sorting ...
}
return strcmp(((const_text_scrollitem_t *)aa)->get_text(), ((const_text_scrollitem_t *)bb)->get_text());
};
And it has no red underlines. The get_ -stuff I just putted in there to get something. That should ofcorse be more precise later.

When I try to compile al this, I get these four errors, saying basicaly the same thing:

Code: [Select]
Error 1 error C2512: 'gui_scrolled_list_t::const_text_scrollitem_t' : no appropriate default constructor available F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans
Error 2 error C2512: 'gui_scrolled_list_t' : no appropriate default constructor available F:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans
3 IntelliSense: no instance of constructor "gui_scrolled_list_t::gui_scrolled_list_t" matches the argument list f:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 18 5 Simutrans
4 IntelliSense: no default constructor exists for class "gui_scrolled_list_t::const_text_scrollitem_t" f:\Spel\Utveckla Simutrans\Simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\vehiclelist_frame_t.cc 19 1 Simutrans


The top of the .cc-file (under the #includes) is where the problem is, I suppose.
It looks like this:
Code: [Select]
vehiclelist_frame_t::vehiclelist_frame_t() :
gui_frame_t(translator::translate("Vehicle list"))
{
}
Here, the third line (with the "{") has a red underline, saying: No defult constructer exist for 'gui_scrolled_list_t::const_text_scrollitem_t'
I look in all kinds of files, to get an impression of what a constructor really is, and moreover what "constructor" I need, but I completely fail here.....

I couldnt make any sence of the "scrollitem_t t;" that you wrote about, prissi. When I put it in the header file, it complains that it is not allowed, that it is a pure virtual function. How would you suggest me to use it?

Am I at all supposed to create a constructor, and since I dont know how, how do I do that?

If anyone wants to comment and/or are willing to push a newbie a little bit in the right direction, just do it! :)
Title: Re: List of available vehicles (without building depot)
Post by: prissi on December 08, 2014, 10:32:56 PM
Sorry, I missed this. If you still work on this: You need to have a vehicle_scrollitem_t which is derived from gui_scrolled_list_t::scrollitem_t. Then this scrollitem need a constructor which takes the besch as parameter.

Using this logic, the list will handle almost everything else by itself.
Title: Re: List of available vehicles (without building depot)
Post by: Yona-TYT on December 09, 2014, 03:45:22 AM
@Ves
I hope you have not abandoned the project.  :P
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 09, 2014, 01:18:53 PM
ok, Im on another computer, so I cant check in the code right now. Am I supposed to create vehicle_scrollitem_t and derive from the gui_scrolled_list::scrollitem_t or is it already there?
I searched trhough the internet about "derive a class" and found some links that I will check.
I will experiement with this as soon I get back to my computer! :-)
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 15, 2014, 06:03:43 PM
Finally Im getting somewhere!
I created a new class called vehicle_scrollitem_t and after some work, I made it compile again! There is nothing to show at the moment other than the new blank window.
I struggle at the moment to make a correct constructor, I cant really find other usefull constructors based on scrolled list.
When i (in class vehiclelist_frame_t) write:"vehicle_scrollitem_t t;", there is a red underline under the little "t" stating:

ERROR: object of abstract class type "vehicle_scrollitem_t" is not allowed:
Pure virtual function "gui_scrolled_list::scrollitem::get_h" has no overrider
Pure virtual function "gui_scrolled_list::scrollitem::draw" has no overrider
Pure virtual function "gui_scrolled_list::scrollitem::get_text" has no overrider

I found in some code this line:

char const* get_text() const OVERRIDE;

, which I inserted and got rid of one of the errors. I tried to do the same with the other two, but it wouldn allow me to do that.

What am I doing wrong?
Title: Re: List of available vehicles (without building depot)
Post by: prissi on December 15, 2014, 09:17:07 PM
In your class you need to define these functions, i.e. must return the height of the hieghest item, need a fuction to draw and must return a text (like translator::translate(besch->get_name());)
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 17, 2014, 12:08:08 AM
Ah, ofcorse! (Trying to sound as that was obvious ;-) )

I just keep on digging!
Title: Re: List of available vehicles (without building depot)
Post by: Václav on December 19, 2014, 11:49:32 AM
I support this extension. But where to place button (or so) to show it?
Title: Re: List of available vehicles (without building depot)
Post by: Yona-TYT on December 19, 2014, 12:08:20 PM

I support this extension. But where to place button (or so) to show it?
List Manager perhaps. ???
Title: Re: List of available vehicles (without building depot)
Post by: Václav on December 19, 2014, 12:14:00 PM
Yes, I think so. It is usable place. And there vehicles could be filtered by type or so, too.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 20, 2014, 06:16:10 AM
That is the place i put the window. Everyone agrees that this is the place to put it?
Title: Re: List of available vehicles (without building depot)
Post by: Spenk009 on December 20, 2014, 09:45:59 AM
I agree, since it's a list it fits in there perfectly.

What thumbnail have you chosen?
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 20, 2014, 12:42:06 PM
I have made it possible to paint a new tumbnail, now I just use the signlist-thumbnail.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 28, 2014, 09:38:22 PM
Im slowly getting forward, now the compile complaints with this error:

Code: [Select]
Error 2 error C2064: term does not evaluate to a function taking 2 arguments f:\spel\utveckla simutrans\simutrans källkod\simutrans.14.05.29\simutrans\trunk\tpl\vector_tpl.h 140 1 Simutrans

I have a strong suspicion that it is when i try to "fill list" I get that error. If I remove that section it compiles. I fail totally to figure out how to solve it, and it doesnt help that the error points to the vector-file instead of where in my code the problem is.

any ideas?
Title: Re: List of available vehicles (without building depot)
Post by: Ters on December 28, 2014, 09:52:14 PM
Line 140 in trunk vector_tpl.h is a call to the comparator function passed to insert_ordered. The comparator function you pass isn't a function taking two arguments. If I'm going to guess, it's because you pass a non-static member function, which has an implicit third parameter.
Title: Re: List of available vehicles (without building depot)
Post by: Ves on December 28, 2014, 10:03:03 PM
ah ok, so the class im trying to compare is having different amount of parameters than two?
Maybe also showing the output-section of the compiler could be helpfull to narrow down the problem

Code: [Select]
1>------ Build started: Project: Simutrans, Configuration: Release Win32 ------
1>  vehiclelist_frame_t.cc
1>gui\vehiclelist_frame_t.cc(18): warning C4005: 'SCL_HEIGHT' : macro redefinition
1>          f:\spel\utveckla simutrans\simutrans källkod\simutrans.14.05.29\simutrans\trunk\gui\extend_edit.h(22) : see previous definition of 'SCL_HEIGHT'
1>f:\spel\utveckla simutrans\simutrans källkod\simutrans.14.05.29\simutrans\trunk\dataobj\../tpl/vector_tpl.h(140): error C2064: term does not evaluate to a function taking 2 arguments
1>          gui\vehiclelist_frame_t.cc(95) : see reference to function template instantiation 'void vector_tpl<const vehikel_besch_t *>::insert_ordered<vehicle_scrollitem_t::sort_modes_t>(const T &,StrictWeakOrdering)' being compiled
1>          with
1>          [
1>              T=const vehikel_besch_t *
1>  ,            StrictWeakOrdering=vehicle_scrollitem_t::sort_modes_t
1>          ]
1>          gui\vehiclelist_frame_t.cc(95) : see reference to function template instantiation 'void vector_tpl<const vehikel_besch_t *>::insert_ordered<vehicle_scrollitem_t::sort_modes_t>(const T &,StrictWeakOrdering)' being compiled
1>          with
1>          [
1>              T=const vehikel_besch_t *
1>  ,            StrictWeakOrdering=vehicle_scrollitem_t::sort_modes_t
1>          ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Title: Re: List of available vehicles (without building depot)
Post by: Ters on December 28, 2014, 11:30:17 PM
ah ok, so the class im trying to compare is having different amount of parameters than two?

No, not the class you are comparing. It's the function you are, directly or indirectly, telling vector_tpl to use when comparing two vehicle_besch_t instances in insert_ordered.

And the code with problems is at line 95 in vehiclelist_frame_t.cc
Title: Re: List of available vehicles (without building depot)
Post by: prissi on January 06, 2015, 10:59:12 PM
The comparing function ususally need to be static, since it is very tricky to init them with the corretc object in derived types.