eclipse plugin: use the wmlparser to get the scenario id
This commit is contained in:
parent
2fb54dd298
commit
efcc883671
4 changed files with 32 additions and 12 deletions
|
@ -27,7 +27,14 @@ public class GameUtils
|
|||
*/
|
||||
public static void runCampaign()
|
||||
{
|
||||
runCampaignScenario(false);
|
||||
Thread gameThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
runCampaignScenario(false);
|
||||
}
|
||||
});
|
||||
gameThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +42,14 @@ public class GameUtils
|
|||
*/
|
||||
public static void runScenario()
|
||||
{
|
||||
runCampaignScenario(true);
|
||||
Thread gameThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
runCampaignScenario(true);
|
||||
}
|
||||
});
|
||||
gameThread.start();
|
||||
}
|
||||
|
||||
protected static void runCampaignScenario(boolean scenario)
|
||||
|
@ -112,7 +126,6 @@ public class GameUtils
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (extraArgs != null)
|
||||
args.addAll(extraArgs);
|
||||
|
||||
|
|
|
@ -244,11 +244,10 @@ public class ProjectUtils
|
|||
*/
|
||||
public static String getScenarioID(IResource resource)
|
||||
{
|
||||
return getConfigKeyValue(resource.getLocation().toOSString(), "id");
|
||||
// WMLSaxHandler handler = getWMLHandlerFromResource(resource.getLocation().toOSString());
|
||||
// if (handler == null)
|
||||
// return null;
|
||||
// return handler.ScenarioId;
|
||||
WMLSaxHandler handler = getWMLHandlerFromResource(resource.getLocation().toOSString());
|
||||
if (handler == null)
|
||||
return null;
|
||||
return handler.ScenarioId;
|
||||
}
|
||||
|
||||
private static WMLSaxHandler getWMLHandlerFromResource(String resourcePath)
|
||||
|
|
|
@ -19,8 +19,8 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
*/
|
||||
public class WMLSaxHandler extends DefaultHandler
|
||||
{
|
||||
public String CampaignId;
|
||||
public String ScenarioId;
|
||||
public String CampaignId = null;
|
||||
public String ScenarioId = null;
|
||||
|
||||
private static Stack<String> stack;
|
||||
public WMLSaxHandler()
|
||||
|
@ -41,9 +41,9 @@ public class WMLSaxHandler extends DefaultHandler
|
|||
{
|
||||
if (stack.peek().equals("id"))
|
||||
{
|
||||
if (stack.contains("campaign"))
|
||||
if (stack.get(stack.size() - 2).equals("campaign"))
|
||||
CampaignId = new String(ch, start, length);
|
||||
else if (stack.contains("scenario"))
|
||||
else if (stack.get(stack.size() - 2).equals("scenario"))
|
||||
ScenarioId = new String(ch, start, length);
|
||||
}
|
||||
super.characters(ch, start, length);
|
||||
|
|
|
@ -89,6 +89,14 @@ public class WMLTools
|
|||
arguments.add("-w");
|
||||
arguments.add(Preferences.getString(Constants.P_WESNOTH_EXEC_PATH));
|
||||
|
||||
// add user data directory
|
||||
arguments.add("-c");
|
||||
arguments.add(Preferences.getString(Constants.P_WESNOTH_USER_DIR));
|
||||
|
||||
// add the working data directory
|
||||
arguments.add("-a");
|
||||
arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR));
|
||||
|
||||
// input file
|
||||
arguments.add("-i");
|
||||
arguments.add(resourcePath);
|
||||
|
|
Loading…
Add table
Reference in a new issue