I/O reworking
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
I/O reworking
by silly freak » 20 Aug 2009, 20:54
hi!
I want to rework the current system of finding files, which is mostly "everything is in the current working directory". In my opinion, it's only necessary to keep one file in an expected location, and everything else can be referenced there. this would save the "save all-decks and move it back" by just pointing to the old one.
i have already worked out a class for handling this in a very flexible and easy-to-use way (both from programmer's and user's perspective). the important thing now is to know at what places forge metions external sources, from card images to decks, rarities and so on. would be nice if someone already had a list
PS: i would post the source now, but don't have my USB stick handy...
I want to rework the current system of finding files, which is mostly "everything is in the current working directory". In my opinion, it's only necessary to keep one file in an expected location, and everything else can be referenced there. this would save the "save all-decks and move it back" by just pointing to the old one.
i have already worked out a class for handling this in a very flexible and easy-to-use way (both from programmer's and user's perspective). the important thing now is to know at what places forge metions external sources, from card images to decks, rarities and so on. would be nice if someone already had a list
PS: i would post the source now, but don't have my USB stick handy...
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by mtgrares » 21 Aug 2009, 17:28
Let me try to briefly explain all of the external files that MTG Forge reads.The important thing now is to know at what places forge metions external sources, from card images to decks, rarities and so on. would be nice if someone already had a list.
all-decks2 - holds all of the decks, I think DeckIO creates this file
AllTokens.txt - holds info relating to tokens
booster-decks - holds only booster decks, this tries to prevent some booster deck IO problems
card-pictures.txt - gets card pics and URL
cards.txt - raw text on Magic cards
common.txt, uncommon.txt, rare.txt - used to create packs for sealed and booster draft, I think ReadBoosterPack or something like it reads these files
name-mutator.txt - Used by NameChanger.java (I think) and CardFactory, this is old and can be removed except that some of the code tries to read it, so I haven't deleted it just to make everything work, this renames all of the Magic cards (at the time).
quest-common.txt, quest-rare.txt, quest-uncommon.txt - used by Quest_ReadBoosterDraft to create packs that are won during a quest
questData - holds quest save data, cardpool, human and AI decks
questDecks-easy.txt, questDecks-hard.txt, questDecks-medium.txt - stores which AI decks are easy, med, or hard read by QuestData.java (I think)
tokens.txt - I don't know if this file is currently used or is old
Technically the Gui_DeckEditor.java reads up.gif and down.gif and uses the pictures for the add and remove buttons but these files aren't required (apparantly).
- mtgrares
- DEVELOPER
- Posts: 1352
- Joined: 08 Sep 2008, 22:10
- Has thanked: 3 times
- Been thanked: 12 times
Re: I/O reworking
by Rob Cashwalker » 21 Aug 2009, 19:58
tokens.txt isn't part of MTGForge proper. I put it together at one point to support the card generator.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: I/O reworking
by silly freak » 21 Aug 2009, 23:34
thanks for the tips, I was more interested in references in the source code
nonetheless, i have something to present. changing all the file accesses in forge will take a little longer, but two things are ready:
the first is the source of my property files mechanism. the class javadoc of TreeProperties should explain it quite well
the second are properties-files and the normal forge files in a new structure that I prefer. the structure is of course not mandatory, it's just my two cents
Interesting is that the only line in forge.properties states that the real properties are somewhere else
EDIT: i replaced the properties-archive, it contained the out-of-date quest data. and now, i don't get errors anymore, so i can also share the changes I had to make to the forge code
nonetheless, i have something to present. changing all the file accesses in forge will take a little longer, but two things are ready:
the first is the source of my property files mechanism. the class javadoc of TreeProperties should explain it quite well
the second are properties-files and the normal forge files in a new structure that I prefer. the structure is of course not mandatory, it's just my two cents
Interesting is that the only line in forge.properties states that the real properties are somewhere else
EDIT: i replaced the properties-archive, it contained the out-of-date quest data. and now, i don't get errors anymore, so i can also share the changes I had to make to the forge code
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by silly freak » 11 Sep 2009, 17:38
i'm pretty much done with what i wanted to do. that is:
- all file accesses in forge now use configurable locations from the properties files
- forge is somewhat "internationalization-ready".
the parts that can be translated are- some dialogs of the BoosterDraft screen
- big parts of GuiDisplay3 - including menus and zones
- the picture download window
- the error viewer (it will also work - in english - if the language files are missing)
- the how to play window - uses the new version by chris
- the menus of Gui_NewGame
- the L&F list is generated from UIManager.getInstalledLookAndFeels
- Gui_NewGame and GuiDisplay3 contain a menu item for showing an error report. this may help for the "computer is thinking" error, if it doesn't shut down the gui
- i have renewed the list choosing dialog:
- you can close the dialog by double clicking an option
- it uses generics - you don't have to cast the result to the original type
- it's possible to specify both the minimum and the maximum number of choices: 0,1 is an optional choice, 1,1 is a mandatory choice. 1,Integer.MAX_VALUE would be one or more.
- the new dialog is used in Display.getChoice[Optional], and for the card size and L&F choosers
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by DennisBergkamp » 14 Sep 2009, 00:15
Do these files include your updates ? (which, looking at the list, look awesome by the way!)
I think it's time for a new version soon, so I'm starting to merge everything that's been submitted
I like your new way of packaging the Forge, I think we should go for that one.
I think it's time for a new version soon, so I'm starting to merge everything that's been submitted
I like your new way of packaging the Forge, I think we should go for that one.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: I/O reworking
by silly freak » 14 Sep 2009, 09:35
these two archives include the same information. that is, the external forge files (such as cards.txt, all-decks2 and so on), including additional property files by me for internationalization and such. these files include the how-to as discussed
the difference between the both is that the "classic" archive contains all existing files in the root folder, and the "new" archive contains them in a separate folder.
so, if you're okay with it, i'll move all existing classes to the "forge" packages, and you get the files that changed beyond that.
the difference between the both is that the "classic" archive contains all existing files in the root folder, and the "new" archive contains them in a separate folder.
so, if you're okay with it, i'll move all existing classes to the "forge" packages, and you get the files that changed beyond that.
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by silly freak » 14 Sep 2009, 10:52
ok, i've tried to move the classes in the forge package, but it makes a few problems. deserialization doesn't work when the class name changes from "Deck" to "forge.Deck".
i'm trying to find a solution...
i'm trying to find a solution...
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by silly freak » 15 Sep 2009, 20:32
okay, I need more time to figure the serialization problems out. for the next version, this is the code without packages. some new classes don't need anything from forge, they are in packages already.
new classes added are
forge.gui.ListChooser - The new dialog already metioned
ForgeAction - a javax.swing.Action subclass that makes internationalization easy.
ForgeProps - the access point for getting properties
forge.properties.NewConstants - the property keys to use with ForgeProps
changed classes are mostly for file location- and language changes. in CardFactory, this means only the first ~100 lines.
small update to the code: the language is configured in res/lang/lang.properties. my new version takes the language of the default locale if that key is not present, so i'd recommend to take the key out of the released version
new classes added are
forge.gui.ListChooser - The new dialog already metioned
ForgeAction - a javax.swing.Action subclass that makes internationalization easy.
ForgeProps - the access point for getting properties
forge.properties.NewConstants - the property keys to use with ForgeProps
changed classes are mostly for file location- and language changes. in CardFactory, this means only the first ~100 lines.
small update to the code: the language is configured in res/lang/lang.properties. my new version takes the language of the default locale if that key is not present, so i'd recommend to take the key out of the released version
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by silly freak » 19 Sep 2009, 09:01
oops, i forgot the attachment
btw, I moved the ErrorViewer to package forge.error, so there are a few imports to add. That way, i could move more classes into packages (namely ForgeProps and ForgeAction). i'd suggest to move ErrorViewer before merging the new code, then eclipse does the imports by itself.
and finally, here are the classes.
btw, I moved the ErrorViewer to package forge.error, so there are a few imports to add. That way, i could move more classes into packages (namely ForgeProps and ForgeAction). i'd suggest to move ErrorViewer before merging the new code, then eclipse does the imports by itself.
and finally, here are the classes.
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by DennisBergkamp » 19 Sep 2009, 16:45
Alright. I'll see if I can figure out how to merge everything
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: I/O reworking
by DennisBergkamp » 21 Sep 2009, 01:17
Silly Freak,
Hmm, I get a bunch of errors in ForgeProps.java when I add these packages to the project. It says it can't find TreeProperties
Can't even find the import (treeproperties.TreeProperties). Where do I get it ?
Hmm, I get a bunch of errors in ForgeProps.java when I add these packages to the project. It says it can't find TreeProperties
Can't even find the import (treeproperties.TreeProperties). Where do I get it ?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: I/O reworking
by silly freak » 21 Sep 2009, 09:49
again a piece of code i forgot to upload
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: I/O reworking
by DennisBergkamp » 21 Sep 2009, 20:34
Ok, I think I've merged everything (impressive changes!). But I think the forge.properties file is missing? I can't find it anywhere, and after compiling I can't run the program without it
Also, I think you forgot to post the changes you made to PicturePanel.java, I kind of changed it myself so that it accepts a File instead of a String (and I think it should work - no compilation errors). But maybe you could post your version just to be sure
Also, I think you forgot to post the changes you made to PicturePanel.java, I kind of changed it myself so that it accepts a File instead of a String (and I think it should work - no compilation errors). But maybe you could post your version just to be sure
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: I/O reworking
by silly freak » 21 Sep 2009, 21:22
I said it - i'm continuously forgetting code. but seriously, i don't know how i missed that one:
and don't forget to delete the lang-entry from lang/lang.properties for the released version
- Code: Select all
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import forge.error.ErrorViewer;
public class PicturePanel extends JPanel {
private static final long serialVersionUID = 2282867940272644768L;
public PicturePanel(File f) {
if(!f.exists()) {
ErrorViewer.showError("PicturePanel : file does not exist - %s", f);
throw new RuntimeException("PicturePanel : file does not exist - " + f);
}
ImageIcon i = new ImageIcon(f.getPath());
this.add(new JLabel(i));
}
}
and don't forget to delete the lang-entry from lang/lang.properties for the released version
___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
33 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 87 guests