ElSid wrote:My question is why ExpWnd is end up in the game resources and haven.BuddyWnd with its all tabs and subtabs in the client source?
Ok, sure, that isn't always a fully consistent decision, and there are a couple of aspects I balance when consdering that. Sometimes it's really just for legacy reasons (because something has been part of the client since before I started putting stuff into resources), sometimes it's just because it's something I find particularly reasonable that clients modders should have access to (like CharWnd or GameUI, which I otherwise really would like to put into resources). Sometimes it's because something is expected to have a consistent protocol against the server anyway and I suspect it is more useful to be able to modify it in the client without (on a contrary point to the one I made earlier) having to do a server/resource update. For some things it can be quite a complex decision whether to put it into a resource or not.
ElSid wrote:I mentioned markdown language as an example. I haven't written "programming language" just "language". A some set of rules that can describe a widget only from a visual point of view (e.g. place a button with text "foo" and width 100 at position 50, 100, a label with text "bar" at 50, 50, and a picture from "gfx/baz" resource at 0, 0). But as I said it might be an overkill.
Overkill aside (though I agree it probably would be), the real problem is that a widget is rarely just a graphical layout thing. More often than not, they need behavior as well. To the extent that they only are "layout-related", I tend to use the "
relpos" DSL (the one in
Widget.java) for layout specifications instead of widget code in resources.
ElSid wrote:Instead I want each widget that is stored as a resource to be more customizable on initialization. For example ExpWnd adds child widgets in the method tick:
Now that I've seen your other thread, I understand better what it is that you're after, but the issue with the solution you're proposing is that it's only really useful for your specific case, and most other systems like it have the same issue. They only solve one particular angle of customization, add a lot of complexity for that singular purpose, and are pretty much useless for everyone else. Also, while I realize that your example wasn't meant to convey a completely thought-through solution or anything, it has the major issue of definitely requiring updates to the main codebase for every "codeful" resource added, which completely defeats the purpose.
I suspect that a seed of an idea for a solution to the problem of resource code would be to able to allow custom clients to create subclasses of classes defined in resources (to be used in place of the original class, but still inheriting it) in order to more selectively override behavior (that would allow non-overridden methods to still be updated with newer versions of the resource while still allowing changes to the behavior to persist over such updates). Even such a solution wouldn't be ideal, though (since it would still depend on the code in the resource to have the appropriate overridable methods for important things, and, as already discussed, it's going to be impossible to completely predict and preempt every desirable angle of customization), but it would probably be better than nothing. Arguably the real problem with that solution is just getting
javac in the development environment to be able to get code from resources onto its classpath, and I really don't know how to solve that issue.