From: Erik V. <eri...@hc...> - 2005-09-18 22:00:44
|
I have added Trains. Most options related to buying trains have been implemented, except - buying "unlimited" trains, - cheap exchange for first Diesel, - train limits (will come when Phases are added), - dual trains, like 18VA 4/3G or 18Scan 4/3+3. I am thinking about ways to simplify keeping all data shown in the UI up to date. Sometimes "deep" changes occur (such as new trains becoming available), and now the UI must poll each time a train is bought if such a change has occurred. The same applies to share prices, cash amounts, and in fact all on-screen items. It could be easier to have the values "tell" the UI about any changes. Two ways to achieve that are 1. Create an Event each time a values changes, and let each and every UI field listen to changes of its underlying value. 2. An older and IMO simpler way is the Observer/Observable pattern. The main hurdle is that each such value must get the capability to register its own listener(s). I played a bit with Events and EventListeners but it looks rather heavy to me. The simplest solution might be to create Observable subclass types (ObservableInteger etc.) and embed values like cash amounts and share percentages in such types. The UI Field class should then implement Observer, and each Field instance should register as an Observer of its own Observable. Any thoughts about this idea? Erik. |