void XmlMapHandler::ReadAnimation(wxXmlNode* root, Map& map) { VerboseLog("Reading an animation"); wxXmlNode* child = root->GetChildren(); std::string name; int32_t delay; int32_t type; int32_t times; std::vector<int32_t> frames; while (child) { std::string property = child->GetName().ToStdString(); std::string content = child->GetNodeContent().ToStdString(); VerboseLog("%s Got node %s content %s", __func__, property.c_str(), content.c_str()); Scanner scanner(content); if (property == "Name") { name = content; } else if (property == "Delay") { if (!scanner.Next(delay)) throw "Could not parse name"; } else if (property == "Type") { if (!scanner.Next(type)) throw "Could not parse type"; } else if (property == "Times") { if (!scanner.Next(times)) throw "Could not parse times"; } else if (property == "Frames") { while (scanner.HasMoreTokens()) { int32_t element; if (!scanner.Next(element)) throw "Could not parse frames"; frames.push_back(element); } } else { throw "Unexpected token " + property; } child = child->GetNext(); } map.Add(AnimatedTile(name, delay, static_cast<AnimatedTile::Type>(type), times, frames)); VerboseLog("Done Reading an Animation"); }
void I_updateGameInput() { if(PointinRect(Point(input.mouse.lX,input.mouse.lY),rmenuRect)) { if( input.mouse.buttonPressed(MLBUTTON)) selectedBrush = highlightedBrush; } else if(PointinRect(Point(input.mouse.lX,input.mouse.lY),s_dstRect)) { if(input.mouse.buttonDown(MLBUTTON)) { if(!input.keyboard.keyDown(VK_CONTROL)) selectedTile = highlightedTile; else { if(pselected_tilemap->t_mapSize.x && pselected_tilemap->t_mapSize.y && beditimage) pselected_tilemap->imageLayer[highlightedTile.x][highlightedTile.y].tileIndex = selectedBrush; if(pselected_tilemap->has_c_Map && beditcollisions) pselected_tilemap->collisionLayer[highlightedTile.x][highlightedTile.y].tileIndex = selectedCBrush; if(isAnimatedTile(selectedBrush)) { pselected_tilemap->animatedTiles.push_back(AnimatedTile(Point(highlightedTile.x,highlightedTile.y),tileAnimations[selectedBrush - 240])); pselected_tilemap->imageLayer[highlightedTile.x][highlightedTile.y].atileIndex = selectedBrush; } else { for(int i=0;i<pselected_tilemap->animatedTiles.size();i++) { if(pselected_tilemap->animatedTiles[i].position.x == highlightedTile.x && pselected_tilemap->animatedTiles[i].position.y == highlightedTile.y) remove(pselected_tilemap->animatedTiles,i); } pselected_tilemap->imageLayer[highlightedTile.x][highlightedTile.y].atileIndex = 0; } } } } else if(PointinRect(Point(input.mouse.lX,input.mouse.lY),lmenuRect)) { if( input.mouse.buttonPressed(MLBUTTON)) selectedCBrush = highlightedCBrush; } if( input.keyboard.keyDown('Q')) camera.Zoom(10.0f); if( input.keyboard.keyDown('E')) camera.Zoom(-10.0f); if( input.keyboard.keyPressed('D')) camera.toMove.x = 1; if( input.keyboard.keyPressed('A')) camera.toMove.x = -1; if( input.keyboard.keyPressed('W')) camera.toMove.y = 1; if( input.keyboard.keyPressed('S')) camera.toMove.y = -1; if( input.keyboard.keyReleased('D')) camera.toMove.x==1?camera.toMove.x=0:NULL; if( input.keyboard.keyReleased('A')) camera.toMove.x==-1?camera.toMove.x=0:NULL; if( input.keyboard.keyReleased('W')) camera.toMove.y==1?camera.toMove.y=0:NULL; if( input.keyboard.keyReleased('S')) camera.toMove.y==-1?camera.toMove.y=0:NULL; }