Пример #1
0
  protected void init(final ArcadeData data) {
    clear();
    add(_header = new FBGameHeaderPanel());
    _header.initWithCards(data.allGames);

    // top games
    FlowPanel topGames = MsoyUI.createFlowPanel("TopGames");
    topGames.add(MsoyUI.createLabel("Top 10 Games", "title"));
    add(topGames);
    DOM.setStyleAttribute(topGames.getElement(), "position", "absolute");
    int ii;
    for (ii = 0; ii < data.topGames.size(); ii++) {
      topGames.add(createTopGameWidget(ii + 1, data.topGames.get(ii)));
    }

    // pad out for testing
    if (data.topGames.size() > 0) {
      for (; ii < 10; ++ii) {
        int rnd = (int) (Math.random() * data.topGames.size());
        topGames.add(createTopGameWidget(ii + 1, data.topGames.get(rnd)));
      }
    }

    // featured games
    // add(new FBFeaturedGamePanel(data.featuredGames));
    add(new FBMochiGamePanel(data.mochiGames));

    // game wall
    AbsolutePanel gameWall = new AbsolutePanel();
    gameWall.setStyleName("GameWall");
    gameWall.add(MsoyUI.createLabel("Featured Games", "title"));
    SmartTable grid = new SmartTable("Grid", 0, 0);
    gameWall.add(grid);
    int cell = 1;
    for (GameCard wallGame : data.gameWall) {
      grid.setWidget(cell / 3, cell % 3, createWallGameWidget(wallGame), 1, "WallCell");
      cell++;
    }

    // pad out for testing
    if (data.topGames.size() > 0) {
      for (; cell <= 20; cell++) {
        int rnd = (int) (Math.random() * data.topGames.size());
        grid.setWidget(
            cell / 3, cell % 3, createWallGameWidget(data.topGames.get(rnd)), 1, "WallCell");
      }
    }

    add(gameWall);
  }
Пример #2
0
 protected void addGame(SmartTable table, int row, int startCol, GameCard game) {
   table.setWidget(
       row,
       startCol,
       new ThumbBox(
           game.thumbMedia, MediaDescSize.HALF_THUMBNAIL_SIZE, Pages.GAMES, "d", game.gameId));
   Widget link = Link.createBlock(game.name, "Name", Pages.GAMES, "d", game.gameId);
   if (game.playersOnline == 0) {
     table.setWidget(row, startCol + 1, link, 1, "Info");
   } else {
     FlowPanel bits = new FlowPanel();
     bits.add(link);
     bits.add(MsoyUI.createLabel(_msgs.featuredOnline("" + game.playersOnline), "tipLabel"));
     table.setWidget(row, startCol + 1, bits);
   }
 }
Пример #3
0
 protected void createUploadInterface() {
   _upload = new AbsolutePanel();
   _upload.setStyleName("GetStuff");
   _upload.add(MsoyUI.createLabel(_msgs.getStuffTitle(), "GetStuffTitle"), 60, 10);
   _upload.add(MsoyUI.createHTML(_dmsgs.xlateGetStuffBuy(_type), "GetStuffBuy"), 165, 85);
   _upload.add(MsoyUI.createHTML(_dmsgs.xlateGetStuffCreate(_type), "GetStuffCreate"), 360, 85);
   _upload.add(
       new StretchButton(
           StretchButton.BLUE_THICK,
           _msgs.getStuffShop(),
           Link.createHandler(Pages.SHOP, _type + "")),
       10,
       90);
   _upload.add(
       MsoyUI.createButton(
           MsoyUI.MEDIUM_THICK, _msgs.getStuffUpload(), NaviUtil.onCreateItem(_type, 0)),
       535,
       90);
 }
Пример #4
0
  public void setGameDetail(final GameDetail detail) {
    final GameInfo info = detail.info;
    CShell.frame.setTitle(info.name);

    // keep our requested game id around
    _gameId = detail.gameId;

    VerticalPanel shot = new VerticalPanel();
    shot.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
    shot.add(new ThumbBox(info.shotMedia, MediaDescSize.GAME_SHOT_SIZE));
    shot.add(WidgetUtil.makeShim(5, 5));
    Rating rating =
        new Rating(
            info.rating,
            info.ratingCount,
            detail.memberRating,
            false,
            new RateService() {
              public void handleRate(byte newRating, InfoCallback<RatingResult> callback) {
                _gamesvc.rateGame(_gameId, newRating, callback);
              }
            },
            null);

    shot.add(rating);
    HorizontalPanel mbits = new HorizontalPanel();
    mbits.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    mbits.add(
        MsoyUI.makeShareButton(
            Pages.GAMES,
            Args.compose("d", _gameId),
            _msgs.gdpGame(),
            info.name,
            info.description,
            info.shotMedia));
    shot.add(mbits);
    setWidget(0, 0, shot);
    getFlexCellFormatter().setRowSpan(0, 0, 2);
    getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP);

    setWidget(0, 1, new GameNamePanel(info.name, info.genre, info.creator, info.description), 2);

    setWidget(1, 0, new GameBitsPanel(detail));

    FlowPanel play = new FlowPanel();
    play.setStyleName("playPanel");
    play.add(PlayButton.createLarge(_gameId));
    if (info.playersOnline > 0) {
      play.add(MsoyUI.createLabel(_msgs.featuredOnline("" + info.playersOnline), "Online"));
    }
    if (!info.integrated) {
      play.add(MsoyUI.createLabel(_msgs.gdpNoCoins(), null));
    }
    setWidget(1, 1, play, 1, "Play");
    getFlexCellFormatter().setHorizontalAlignment(1, 1, HasAlignment.ALIGN_CENTER);

    // add "Discussions" (if appropriate) and "Shop" button
    Widget buttons = null;
    if (info.groupId > 0) {
      ClickHandler onClick = Link.createHandler(Pages.GROUPS, "f", info.groupId);
      buttons = MsoyUI.createButton(MsoyUI.LONG_THIN, _msgs.gdpDiscuss(), onClick);
    }
    ClickHandler onShop = Link.createHandler(Pages.SHOP, "g", Math.abs(_gameId));
    PushButton shop = MsoyUI.createButton(MsoyUI.MEDIUM_THIN, _msgs.gdpShop(), onShop);
    buttons = (buttons == null) ? shop : MsoyUI.createButtonPair(buttons, shop);
    setWidget(2, 0, buttons);
    getFlexCellFormatter().setRowSpan(0, 0, 3);
    getFlexCellFormatter().setRowSpan(1, 1, 2);

    setWidget(
        3,
        0,
        _tabs =
            new NaviTabPanel(Pages.GAMES) {
              protected Args getTabArgs(int tabIdx) {
                return getTabCode(tabIdx).args(_gameId);
              }
            },
        3);

    // add the about/instructions tab
    addTab(GameDetails.INSTRUCTIONS, _msgs.tabInstructions(), new InstructionsPanel(detail));

    // add comments tab
    addTab(
        GameDetails.COMMENTS,
        _msgs.tabComments(),
        new LazyPanel() {
          protected Widget createWidget() {
            CommentsPanel comments = new CommentsPanel(CommentType.GAME, info.gameId, true);
            comments.expand();
            return comments;
          }
        });

    // add trophies tab, passing in the potentially negative gameId
    addTab(
        GameDetails.TROPHIES,
        _msgs.tabTrophies(),
        new LazyPanel() {
          protected Widget createWidget() {
            return new GameTrophyPanel(_gameId);
          }
        });

    // add top rankings tabs
    if (!CShell.isGuest()) {
      addTab(
          GameDetails.MYRANKINGS,
          _msgs.tabMyRankings(),
          new LazyPanel() {
            protected Widget createWidget() {
              return new TopRankingPanel(info.gameId, true);
            }
          });
    }
    addTab(
        GameDetails.TOPRANKINGS,
        _msgs.tabTopRankings(),
        new LazyPanel() {
          protected Widget createWidget() {
            return new TopRankingPanel(info.gameId, false);
          }
        });

    // if we're the creator of the game or support, add the metrics and logs tabs
    if (info.isCreator(CShell.getMemberId()) || CShell.isSupport()) {
      // addTab(GameDetails.METRICS, _msgs.tabMetrics(), new LazyPanel() {
      //     protected Widget createWidget () {
      //         return new GameMetricsPanel(detail);
      //     }
      // });
      addTab(
          GameDetails.LOGS,
          _msgs.tabLogs(),
          new LazyPanel() {
            protected Widget createWidget() {
              return new GameLogsPanel(info.gameId);
            }
          });
      addTab(
          GameDetails.DEV_LOGS,
          _msgs.tabDevLogs(),
          new LazyPanel() {
            protected Widget createWidget() {
              return new GameLogsPanel(GameInfo.toDevId(info.gameId));
            }
          });
    }
  }
Пример #5
0
  public StuffPanel(InventoryModels models, int memberId, MsoyItemType type) {
    setStyleName("itemPanel");

    _models = models;
    _memberId = memberId;
    _type = type;
    boolean displayUpload = shouldDisplayUpload(type);

    // prepare the search box
    _search = new HorizontalPanel();
    _search.setStyleName("Search");
    _search.setSpacing(5);
    _search.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
    _search.add(MsoyUI.createLabel(_msgs.stuffSearch(), "SearchTitle"));
    final ListBox searchTypes = new ListBox();
    MsoyItemType[] items =
        CShell.getClientMode().isMinimal() ? MsoyItemType.DJ_ITEMS : MsoyItemType.STUFF_ITEMS;
    for (MsoyItemType searchType : items) {
      searchTypes.addItem(_dmsgs.xlateItemsType(searchType), searchType.toByte() + "");
      if (searchType == type) {
        searchTypes.setSelectedIndex(searchTypes.getItemCount() - 1);
      }
    }
    _search.add(searchTypes);
    _searchBox =
        new SearchBox(
            new SearchBox.Listener() {
              public void search(String query) {
                String type = searchTypes.getValue(searchTypes.getSelectedIndex());
                Link.go(Pages.STUFF, type, _memberId, 0, query);
              }

              public void clearSearch() {
                Link.go(Pages.STUFF, _type, _memberId, 0);
              }
            });
    _search.add(_searchBox);
    _search.add(MsoyUI.createImageButton("GoButton", _searchBox.makeSearchListener()));

    // a drop down for setting filters
    _filters = new ListBox();
    for (String element2 : FLABELS) {
      _filters.addItem(element2);
    }
    _filters.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            showInventory(_mostRecentPage, null);
          }
        });

    // compute the number of rows of items we can fit on the page
    int used = displayUpload ? NAVIGATION_HEIGHT + GET_STUFF_HEIGHT : NAVIGATION_HEIGHT;
    int rows = MsoyUI.computeRows(used, ITEM_BOX_HEIGHT, 2);

    // now create our grid of items
    _contents =
        new PagedGrid<Item>(rows, COLUMNS) {
          @Override
          protected void displayPageFromClick(int page) {
            // route our page navigation through the URL
            Link.go(Pages.STUFF, ((InventoryModels.Stuff) _model).makeArgs(_memberId, page));
          }

          @Override
          protected Widget createWidget(Item item) {
            return new ItemEntry(item, !(item instanceof IdentGameItem));
          }

          @Override
          protected String getEmptyMessage() {
            if (_model instanceof InventoryModels.Stuff) {
              String query = ((InventoryModels.Stuff) _model).query;
              if (query != null) {
                return _msgs.panelNoMatches(query);
              }
            }
            return _msgs.panelNoItems(_dmsgs.xlateItemType(_type));
          }

          @Override
          protected boolean displayNavi(int items) {
            return true;
          }

          @Override
          protected void addCustomControls(FlexTable controls) {
            controls.setText(0, 0, _msgs.ipfTitle());
            controls.getFlexCellFormatter().setStyleName(0, 0, "Show");
            controls.setWidget(0, 1, _filters);
          }
        };
    _contents.addStyleName("Contents");

    // finally optionally add the "create your own" sales blurb
    if (displayUpload) {
      createUploadInterface();
    }
  }
Пример #6
0
  /**
   * Requests that the current inventory page be displayed (clearing out any currently displayed
   * item detail view).
   *
   * @param query If non-null, this query is being applied so data must be reloaded from db
   */
  protected void showInventory(final int page, final String query) {
    // don't fiddle with things if the inventory is already showing
    if (!_contents.isAttached()) {
      clear();
      String title =
          (_type == MsoyItemType.NOT_A_TYPE)
              ? _msgs.stuffTitleMain()
              : (_memberId == CShell.getMemberId())
                  ? _msgs.stuffTitle(_dmsgs.xlateItemsType(_type))
                  : _msgs.stuffTitlePlayer(_dmsgs.xlateItemsType(_type));

      add(MsoyUI.createLabel(title, "TypeTitle"));
      add(_search);
      HorizontalPanel row = new HorizontalPanel();
      row.setVerticalAlignment(HorizontalPanel.ALIGN_TOP);
      MsoyItemType[] items =
          CShell.getClientMode().isMinimal() ? MsoyItemType.DJ_ITEMS : MsoyItemType.STUFF_ITEMS;
      row.add(
          new SideBar(
              new SideBar.Linker() {
                public boolean isSelected(MsoyItemType itemType) {
                  return itemType == _type;
                }

                public Widget createLink(String name, MsoyItemType itemType) {
                  return Link.create(name, Pages.STUFF, itemType, _memberId);
                }
              },
              items,
              null));

      row.add(_contents);
      add(row);
      if (_upload != null) {
        add(_upload);
      }
    }

    // determine which filter predicate we should be using
    final Predicate<Item> pred = FILTERS.get(_filters.getSelectedIndex());

    // maybe we're changing our predicate or changing page on an already loaded model
    SimpleDataModel<Item> model = _models.getModel(_memberId, _type, query, 0);
    if (model != null) {
      _contents.setModel(model.filter(pred), page);
      return;
    }

    // otherwise we have to load
    _models.loadModel(
        _memberId,
        _type,
        query,
        0,
        new InfoCallback<DataModel<Item>>() {
          public void onSuccess(DataModel<Item> result) {
            SimpleDataModel<Item> model = (SimpleDataModel<Item>) result;
            _contents.setModel(model.filter(pred), page);
          }
        });
  }