mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Allow item names to contain $playername (that will be substituted for the player's name).
This commit is contained in:
@@ -184,7 +184,7 @@ public final class Dialogs {
|
||||
((ItemContainerAdapter) itemList.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, context.tileManager, combinedLoot.items));
|
||||
itemList.setAdapter(new ItemContainerAdapter(mainActivity, context.tileManager, combinedLoot.items, context.model.player));
|
||||
|
||||
AlertDialog.Builder db = new AlertDialog.Builder(mainActivity)
|
||||
.setTitle(title)
|
||||
|
||||
@@ -103,7 +103,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
|
||||
// change image and name of the item
|
||||
final TextView itemName = (TextView)findViewById(R.id.bulkselection_itemname);
|
||||
itemName.setText(itemType.name);
|
||||
itemName.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(itemName, itemType, getResources());
|
||||
|
||||
int actionTextResourceID = 0;
|
||||
@@ -190,7 +190,7 @@ public class BulkSelectionInterface extends Activity implements TextWatcher {
|
||||
public void onClick(View v) {
|
||||
if (requiresConfirmation(itemType)) {
|
||||
final String displayType = ItemInfoActivity.getDisplayTypeString(res, itemType).toLowerCase();
|
||||
final String message = res.getString(R.string.bulkselection_sell_confirmation, itemType.name, displayType);
|
||||
final String message = res.getString(R.string.bulkselection_sell_confirmation, itemType.getName(world.model.player), displayType);
|
||||
|
||||
new AlertDialog.Builder(v.getContext())
|
||||
.setIcon(android.R.drawable.ic_dialog_info)
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
});
|
||||
container = player.inventory;
|
||||
wornTiles = world.tileManager.loadTilesFor(player.inventory, getResources());
|
||||
inventoryListAdapter = new ItemContainerAdapter(this, world.tileManager, container, wornTiles);
|
||||
inventoryListAdapter = new ItemContainerAdapter(this, world.tileManager, container, player, wornTiles);
|
||||
inventoryList.setAdapter(inventoryListAdapter);
|
||||
|
||||
heroinfo_stats_gold = (TextView) findViewById(R.id.heroinfo_stats_gold);
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class ItemInfoActivity extends Activity {
|
||||
setContentView(R.layout.iteminfo);
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.iteminfo_title);
|
||||
tv.setText(itemType.name);
|
||||
tv.setText(itemType.getName(world.model.player));
|
||||
world.tileManager.setImageViewTileForSingleItemType(tv, itemType, getResources());
|
||||
tv = (TextView) findViewById(R.id.iteminfo_category);
|
||||
tv.setText(itemType.category.displayName);
|
||||
|
||||
@@ -239,7 +239,7 @@ public final class MainActivity extends Activity {
|
||||
for(int i=0; i<world.model.player.inventory.items.size(); ++i){
|
||||
ItemEntry itemEntry = world.model.player.inventory.items.get(i);
|
||||
if(itemEntry.itemType.isUsable())
|
||||
assignMenu.add(R.id.quick_menu_assign_group, i, Menu.NONE, itemEntry.itemType.name);
|
||||
assignMenu.add(R.id.quick_menu_assign_group, i, Menu.NONE, itemEntry.itemType.getName(world.model.player));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,14 +155,14 @@ public final class ShopActivity extends TabActivity implements OnContainerItemCl
|
||||
private void buy(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
ItemController.buy(world.model, player, itemType, container_buy, quantity);
|
||||
final String msg = getResources().getString(R.string.shop_item_bought, itemType.name);
|
||||
final String msg = getResources().getString(R.string.shop_item_bought, itemType.getName(player));
|
||||
displayStoreAction(msg);
|
||||
}
|
||||
|
||||
private void sell(String itemTypeID, int quantity) {
|
||||
ItemType itemType = world.itemTypes.getItemType(itemTypeID);
|
||||
ItemController.sell(player, itemType, container_buy, quantity);
|
||||
final String msg = getResources().getString(R.string.shop_item_sold, itemType.name);
|
||||
final String msg = getResources().getString(R.string.shop_item_sold, itemType.getName(player));
|
||||
displayStoreAction(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class Constants {
|
||||
public static final String FILENAME_WORLDMAP_HTMLFILE_PREFIX = "worldmap_";
|
||||
public static final String FILENAME_WORLDMAP_HTMLFILE_SUFFIX = ".html";
|
||||
public static final String FILENAME_SAVEGAME_FILENAME_PREFIX = "savegame";
|
||||
|
||||
public static final String PLACEHOLDER_PLAYERNAME = "$playername";
|
||||
|
||||
public static final Random rnd = new Random();
|
||||
public static int rollValue(final ConstRange r) { return rollValue(r.max, r.current); }
|
||||
|
||||
@@ -99,6 +99,6 @@ public final class ConversationController {
|
||||
public static String getDisplayMessage(Phrase phrase, Player player) { return replacePlayerName(phrase.message, player); }
|
||||
public static String getDisplayMessage(Reply reply, Player player) { return replacePlayerName(reply.text, player); }
|
||||
public static String replacePlayerName(String s, Player player) {
|
||||
return s.replace("$playername", player.actorTraits.name);
|
||||
return s.replace(Constants.PLACEHOLDER_PLAYERNAME, player.actorTraits.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,8 +244,8 @@ public final class ItemController {
|
||||
}
|
||||
|
||||
|
||||
public static String describeItemForListView(ItemEntry item) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.name);
|
||||
public static String describeItemForListView(ItemEntry item, Player player) {
|
||||
StringBuilder sb = new StringBuilder(item.itemType.getName(player));
|
||||
if (item.quantity > 1) {
|
||||
sb.append(" (");
|
||||
sb.append(item.quantity);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.item;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.controller.Constants;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
|
||||
public final class ItemType {
|
||||
@@ -12,7 +14,8 @@ public final class ItemType {
|
||||
|
||||
public final String id;
|
||||
public final int iconID;
|
||||
public final String name;
|
||||
private final String name;
|
||||
private final boolean hasPersonalizedName;
|
||||
public final ItemCategory category;
|
||||
public final boolean hasManualPrice;
|
||||
public final int baseMarketCost;
|
||||
@@ -48,6 +51,7 @@ public final class ItemType {
|
||||
this.effects_use = effects_use;
|
||||
this.effects_hit = effects_hit;
|
||||
this.effects_kill = effects_kill;
|
||||
this.hasPersonalizedName = name.contains(Constants.PLACEHOLDER_PLAYERNAME);
|
||||
}
|
||||
|
||||
public boolean isEquippable() { return category.isEquippable(); }
|
||||
@@ -65,6 +69,11 @@ public final class ItemType {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getName(Player p) {
|
||||
if (!hasPersonalizedName) return name;
|
||||
else return name.replace(Constants.PLACEHOLDER_PLAYERNAME, p.actorTraits.name);
|
||||
}
|
||||
|
||||
public int getOverlayTileID() {
|
||||
switch (displayType) {
|
||||
case ItemType.DISPLAYTYPE_QUEST:
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.controller.ItemController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
|
||||
@@ -17,14 +18,16 @@ import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
public final class ItemContainerAdapter extends ArrayAdapter<ItemEntry> {
|
||||
private final TileManager tileManager;
|
||||
private final TileCollection tileCollection;
|
||||
private final Player player;
|
||||
|
||||
public ItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items) {
|
||||
this(context, tileManager, items, tileManager.loadTilesFor(items, context.getResources()));
|
||||
public ItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items, Player player) {
|
||||
this(context, tileManager, items, player, tileManager.loadTilesFor(items, context.getResources()));
|
||||
}
|
||||
public ItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items, TileCollection tileCollection) {
|
||||
public ItemContainerAdapter(Context context, TileManager tileManager, ItemContainer items, Player player, TileCollection tileCollection) {
|
||||
super(context, 0, items.items);
|
||||
this.tileManager = tileManager;
|
||||
this.tileCollection = tileCollection;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +40,7 @@ public final class ItemContainerAdapter extends ArrayAdapter<ItemEntry> {
|
||||
}
|
||||
|
||||
tileManager.setImageViewTile((ImageView) result.findViewById(R.id.inv_image), item.itemType, tileCollection);
|
||||
((TextView) result.findViewById(R.id.inv_text)).setText(ItemController.describeItemForListView(item));
|
||||
((TextView) result.findViewById(R.id.inv_text)).setText(ItemController.describeItemForListView(item, player));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class ShopItemContainerAdapter extends ArrayAdapter<ItemEntry> {
|
||||
}
|
||||
|
||||
tileManager.setImageViewTile((ImageView) result.findViewById(R.id.shopitem_image), itemType, tileCollection);
|
||||
((TextView) result.findViewById(R.id.shopitem_text)).setText(ItemController.describeItemForListView(item));
|
||||
((TextView) result.findViewById(R.id.shopitem_text)).setText(ItemController.describeItemForListView(item, player));
|
||||
Button b = (Button) result.findViewById(R.id.shopitem_shopbutton);
|
||||
if (isSelling) {
|
||||
b.setText(r.getString(R.string.shop_sellitem, ItemController.getSellingPrice(player, itemType)));
|
||||
|
||||
Reference in New Issue
Block a user