示例#1
0
  private void paint_Main(Graphics g) {

    int th = 50; // 标题栏高度
    int ih = 80; // 介绍栏高度
    int ch = gd.screenHeight - th - ih; // 中间列表区域高度
    int gap = 10; // 间距
    int cellW = 160, cellH = 30;
    /** 标题 */
    Painter.drawDialog(g, 0, 0, gd.screenWidth, th, Painter.DIALOG_DEEP);
    g.setFont(Const.Font.FONTLARGE_BOLD);
    g.setColor(Const.Color.GREEN);
    g.drawString("背 包", gd.screenWidth / 2, (th - g.getFont().getHeight()) / 2, Const.Anchor.HT);
    /** 列表 */
    // 底框
    Painter.drawDialog(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_DEEP);
    // 选项卡
    Painter.drawTab(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_LIGHT, gd.bag_tabIndex, tabItems);
    // 列表
    gd.bag_showNum = (ch - 5 * gap) / cellH; // 可显示技能数量
    int space = ch - 3 * gap - gd.bag_showNum * cellH; // 总的竖向剩余空间
    space = space / (gd.bag_showNum + 1); // 间距
    g.setColor(Const.Color.BLACK);
    g.setFont(Const.Font.FONTSMALL_PLAIN);
    Painter.drawTable(
        g,
        (gd.screenWidth - cellW) / 2 - gap / 2,
        th + 3 * gap,
        cellW,
        cellH,
        gd.bag_showNum,
        space,
        gd.bag_tabIndex == 0 ? gd.items : gd.equips,
        Const.Color.BLACK,
        gd.bag_topIndex,
        gd.bag_curIndex,
        Const.Anchor.HV,
        Painter.NODIALOG,
        Painter.CELL_DEEP);

    /** 介绍 */
    Painter.drawDialog(g, 0, th + ch, gd.screenWidth, ih, Painter.DIALOG_DEEP);
    if (gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length > 0
        && gd.player.bag.get(
                gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
            != null) {
      Painter.drawWordWrapString(
          g,
          gd.player.bag.get(
                  gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                  gd.player
                      .bag
                      .getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
              .intro,
          gap / 2,
          th + ch + gap / 2,
          gd.screenWidth - gap,
          ih - gap,
          Const.Color.WHITE);
    }
    /** 滚动条 */
    Painter.drawScrollbar(
        g,
        Painter.SCROLLBAR_VERTICAL,
        (gd.screenWidth - cellW) / 2 + cellW + gap / 2,
        th + 3 * gap + space,
        th + ch - space,
        gd.bag_topIndex,
        gd.bag_showNum,
        gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length);
  }
示例#2
0
文件: Tools.java 项目: heroyuy/systar
 public static void cleanScreen(Graphics g) {
   g.setClip(0, 0, GameData.getGameData().screenWidth, GameData.getGameData().screenHeight);
   g.setColor(0);
   g.fillRect(0, 0, GameData.getGameData().screenWidth, GameData.getGameData().screenHeight);
 }
示例#3
0
 public void release() {
   gd.bag_curIndex = 0; // 回0
 }
示例#4
0
 public void init() {
   BagControl bc = new BagControl();
   setControl(bc);
   gd.buildItems();
 }
示例#5
0
/** @author Administrator */
public class BagView extends BaseView {

  private GameData gd = GameData.getGameData();
  private GameEngine ge = GameEngine.getInstance();
  private String[] tabItems = {"物品", "装备"};
  public static final byte PAGE_MAIN = 0;
  public static final byte PAGE_CONFIRM = 1;
  public static final byte PAGE_TIP = 2;

  public void init() {
    BagControl bc = new BagControl();
    setControl(bc);
    gd.buildItems();
  }

  public void paint(Graphics g) {
    switch (gd.bag_pageIndex) {
      case PAGE_MAIN:
        paint_Main(g);
        break;
      case PAGE_CONFIRM:
        paint_Main(g);
        paint_Confirm(g);
        break;
      case PAGE_TIP:
        paint_Main(g);
        paint_Tip(g);
        break;
    }
  }

  public void release() {
    gd.bag_curIndex = 0; // 回0
  }

  private void paint_Main(Graphics g) {

    int th = 50; // 标题栏高度
    int ih = 80; // 介绍栏高度
    int ch = gd.screenHeight - th - ih; // 中间列表区域高度
    int gap = 10; // 间距
    int cellW = 160, cellH = 30;
    /** 标题 */
    Painter.drawDialog(g, 0, 0, gd.screenWidth, th, Painter.DIALOG_DEEP);
    g.setFont(Const.Font.FONTLARGE_BOLD);
    g.setColor(Const.Color.GREEN);
    g.drawString("背 包", gd.screenWidth / 2, (th - g.getFont().getHeight()) / 2, Const.Anchor.HT);
    /** 列表 */
    // 底框
    Painter.drawDialog(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_DEEP);
    // 选项卡
    Painter.drawTab(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_LIGHT, gd.bag_tabIndex, tabItems);
    // 列表
    gd.bag_showNum = (ch - 5 * gap) / cellH; // 可显示技能数量
    int space = ch - 3 * gap - gd.bag_showNum * cellH; // 总的竖向剩余空间
    space = space / (gd.bag_showNum + 1); // 间距
    g.setColor(Const.Color.BLACK);
    g.setFont(Const.Font.FONTSMALL_PLAIN);
    Painter.drawTable(
        g,
        (gd.screenWidth - cellW) / 2 - gap / 2,
        th + 3 * gap,
        cellW,
        cellH,
        gd.bag_showNum,
        space,
        gd.bag_tabIndex == 0 ? gd.items : gd.equips,
        Const.Color.BLACK,
        gd.bag_topIndex,
        gd.bag_curIndex,
        Const.Anchor.HV,
        Painter.NODIALOG,
        Painter.CELL_DEEP);

    /** 介绍 */
    Painter.drawDialog(g, 0, th + ch, gd.screenWidth, ih, Painter.DIALOG_DEEP);
    if (gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length > 0
        && gd.player.bag.get(
                gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
            != null) {
      Painter.drawWordWrapString(
          g,
          gd.player.bag.get(
                  gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                  gd.player
                      .bag
                      .getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
              .intro,
          gap / 2,
          th + ch + gap / 2,
          gd.screenWidth - gap,
          ih - gap,
          Const.Color.WHITE);
    }
    /** 滚动条 */
    Painter.drawScrollbar(
        g,
        Painter.SCROLLBAR_VERTICAL,
        (gd.screenWidth - cellW) / 2 + cellW + gap / 2,
        th + 3 * gap + space,
        th + ch - space,
        gd.bag_topIndex,
        gd.bag_showNum,
        gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length);
  }

  private void paint_Confirm(Graphics g) {
    int h = 50;
    Painter.drawDialog(g, 0, gd.screenHeight - h, gd.screenWidth, h, Painter.DIALOG_DEEP);
    g.setColor(Color.black);
    if (gd.player.bag.get(
            gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
            gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
        != null) {
      if (gd.bag_tabIndex == 0) {
        g.drawString(
            "是否要使用物品\""
                + (gd.gameObjectManager.getItem(gd.player.bag.getList(Bag.ITEM)[gd.bag_curIndex])
                    .name)
                + "\"",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);

      } else {
        g.drawString(
            "是否要将装备\""
                + (gd.gameObjectManager.getEquip(gd.player.bag.getList(Bag.EQUIP)[gd.bag_curIndex])
                    .name)
                + "\"穿上",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);
      }
    }
  }

  private void paint_Tip(Graphics g) {
    int h = 50;
    Painter.drawDialog(g, 0, gd.screenHeight - h, gd.screenWidth, h, Painter.DIALOG_DEEP);
    g.setColor(Color.black);
    if (gd.bag_tabIndex == 0) {
      g.drawString(
          "使用成功",
          gd.screenWidth / 2,
          gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
          Graphics.TOP | Graphics.HCENTER);

    } else {
      g.drawString(
          "装备成功",
          gd.screenWidth / 2,
          gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
          Graphics.TOP | Graphics.HCENTER);
    }
  }
}
示例#6
0
 public void release() {
   gd.pageIndex = PAGE_MAP;
   gd.xIndex = 0;
   gd.yIndex = 0;
   gd.menuIndex = -1;
 }
示例#7
0
/** 地图视图 */
public class MapView extends BaseView {

  public static final int PAGE_MAP = 0; // 地图行走页面
  public static final int PAGE_MENU = 1; // 菜单界面
  public static final int PAGE_DIALOG = 2; // 对话框界面
  public static final int PAGE_WAIT = 3; // 等待界面
  public static final int MENU_STATE = 0; // 状态
  public static final int MENU_BAG = 1; // 物品
  public static final int MENU_EQUIP = 2; // 装备
  public static final int MENU_SKILL = 3; // 技能
  public static final int MENU_SAVE = 4; // 保存
  public static final int MENU_RETURN = 5; // 返回
  private GameData gd = GameData.getGameData();
  private GameEngine ge = GameEngine.getInstance();
  private RpgGame game = (RpgGame) ge.getGame();

  public void init() {
    MapControl mc = new MapControl();
    setControl(mc);
  }

  /** 绘图 */
  public void paint(Graphics g) {
    Painter.fillRect(g, 0, 0, gd.screenWidth, gd.screenHeight, 0x000000);
    drawMap(g);
    drawPlayer(g);
    switch (gd.pageIndex) {
      case PAGE_MAP:
        break;
      case PAGE_MENU:
        drawMenu(g);
        break;
      case PAGE_DIALOG:
        drawDialog(g);
        break;
      case PAGE_WAIT:
        Painter.drawString(
            g,
            "等待" + (gd.waitTime - gd.waitIndex) + "秒",
            5,
            gd.screenHeight - g.getFont().getHeight(),
            0xffffff);
        break;
    }
  }

  public void release() {
    gd.pageIndex = PAGE_MAP;
    gd.xIndex = 0;
    gd.yIndex = 0;
    gd.menuIndex = -1;
  }

  private void drawDialog(Graphics g) {
    Painter.drawDialog(
        g,
        0,
        gd.screenHeight - g.getFont().getHeight() * 3 - 20,
        gd.screenWidth,
        g.getFont().getHeight() * 3 + 20,
        Painter.DIALOG_DEEP);
    g.setFont(Const.Font.FONTSMALL_PLAIN);
    // 对话人
    Painter.drawString(
        g, gd.dialog_name + ":", 10, gd.screenHeight - g.getFont().getHeight() * 3 - 10, 0xffffff);
    // 两行对话内容
    Painter.drawString(
        g,
        gd.dialog_content[gd.dialog_index],
        10,
        gd.screenHeight - g.getFont().getHeight() * 2 - 10,
        0xffffff);
    if (gd.dialog_index + 1 < gd.dialog_content.length) {
      Painter.drawString(
          g,
          gd.dialog_content[gd.dialog_index + 1],
          10,
          gd.screenHeight - g.getFont().getHeight() - 10,
          0xffffff);
    }
  }

  private void drawMap(Graphics g) {
    g.setColor(0);
    g.fillRect(0, 0, gd.screenWidth, gd.screenHeight);
    //        System.out.println("x:" + gd.curMap.x);
    //        System.out.println("y:" + gd.curMap.y);
    g.drawRegion(
        gd.curMap.image,
        gd.curMap.x,
        gd.curMap.y,
        gd.curMap.image.getWidth() < gd.screenWidth ? gd.curMap.image.getWidth() : gd.screenWidth,
        gd.curMap.image.getHeight() < gd.screenHeight
            ? gd.curMap.image.getHeight()
            : gd.screenHeight,
        0,
        0,
        0,
        0);
  }

  private void drawPlayer(Graphics g) {
    g.drawImage(
        gd.player.getCurCharImg(),
        gd.player.x - gd.curMap.x,
        gd.player.y - gd.curMap.y,
        Graphics.TOP | Graphics.LEFT);
  }

  private void drawMenu(Graphics g) {
    int w = 160, h = 30, gap = 5;
    Painter.drawTable(
        g,
        (gd.screenWidth - w) / 2,
        (gd.screenHeight - Const.Str.MENU_MAP.length * h - (Const.Str.MENU_MAP.length - 1) * gap)
            / 2,
        w,
        h,
        Const.Str.MENU_MAP.length,
        gap,
        Const.Str.MENU_MAP,
        Const.Color.BLACK,
        0,
        gd.map_menuIndex,
        Const.Anchor.HV,
        Painter.NODIALOG,
        Painter.CELL_LIGHT);
  }
}