Exemplo n.º 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);
  }
Exemplo n.º 2
0
  public ConfigAccountPanel() {
    if (CShell.isGuest()
        || CShell.isPermaguest()
        || !MemberMailUtil.isPlaceholderAddress(CShell.creds.accountName)) {
      SmartTable box = new SmartTable(0, 10);
      box.setText(0, 0, _msgs.configNotYou());
      box.setWidget(0, 1, Link.create(_msgs.configHere(), Pages.ACCOUNT, "edit"));
      add(box);
      return;
    }

    int row = 0;
    SmartTable table = new SmartTable(0, 10);
    table.setText(row++, 0, _msgs.configIntro(), 3);
    table.setHTML(row++, 0, "&nbsp;", 3);

    table.setText(row, 0, _msgs.editEmail(), 1, "rightLabel");
    _email = MsoyUI.createTextBox("", MemberName.MAX_EMAIL_LENGTH, -1);
    table.setWidget(row++, 1, _email);
    TextBoxUtil.addTypingListener(_email, _validator);

    table.setText(row, 0, _msgs.configPassword(), 1, "rightLabel");
    table.setWidget(row++, 1, _password = new PasswordTextBox());
    TextBoxUtil.addTypingListener(_password, _validator);

    table.setText(row, 0, _msgs.editConfirm(), 1, "rightLabel");
    table.setWidget(row++, 1, _confirm = new PasswordTextBox());
    TextBoxUtil.addTypingListener(_confirm, _validator);

    table.setHTML(row++, 0, "&nbsp;", 3);
    table.setText(row++, 0, _msgs.configAuthTip(), 3);

    table.setWidget(
        row++,
        2,
        _submit =
            MsoyUI.createButton(
                MsoyUI.MEDIUM_THIN,
                _msgs.configSubmit(),
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    updateAccount();
                  }
                }));
    _submit.setEnabled(false);

    // we use a blank tongue box for formatting consistency with the edit page
    add(new TongueBox(null, table));
  }
Exemplo n.º 3
0
  protected void updateAccount() {
    // make sure the passwords match
    final String password = _password.getText().trim();
    if (!password.equals(_confirm.getText().trim())) {
      MsoyUI.errorNear(_msgs.editPasswordMismatch(), _confirm);
      return;
    }

    // we just let the email address get validated on the server (so lazy!)
    final String email = _email.getText().trim();

    // we could make a special service just for this, but this is fine for this rare page
    _usersvc.updateEmail(
        email,
        new InfoCallback<Void>() {
          public void onSuccess(Void result) {
            CShell.frame.emailUpdated(email, false);
            _usersvc.updatePassword(
                CShell.frame.md5hex(password),
                new InfoCallback<Void>() {
                  public void onSuccess(Void result) {
                    displayThanks();
                  }
                });
          }
        });
  }
Exemplo n.º 4
0
  public RoomsPanel() {
    setStyleName("roomsPanel");

    SmartTable header = new SmartTable("Info", 0, 0);
    header.setWidget(0, 0, new Marquee(null, _msgs.roomsMarquee()), 1);
    header.getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP);
    header.setText(1, 0, _msgs.roomsIntro(), 1, "Intro");

    Widget button =
        MsoyUI.createImageButton(
            "TourButton",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                if (FlashClients.clientExists()) {
                  FlashClients.startTour();
                } else {
                  Link.go(Pages.WORLD, "tour");
                }
              }
            });
    header.setWidget(0, 1, button, 1, "Tour");
    header.getFlexCellFormatter().setRowSpan(0, 1, 2);
    header.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasAlignment.ALIGN_CENTER);

    add(header);

    _worldsvc.loadOverview(
        new InfoCallback<WebRoomService.OverviewResult>() {
          public void onSuccess(WebRoomService.OverviewResult overview) {
            init(overview);
          }
        });
  }
Exemplo n.º 5
0
  public DetailContentPanel(GroupDetail detail) {
    _detail = detail;

    setStyleName("ContentPanel");
    add(_title = MsoyUI.createSimplePanel(null, "ContentPanelTitle"));

    // contains content and discussions button for css min-height
    FlowPanel container = new FlowPanel();
    container.setStyleName("ContentPanelContainer");
    add(container);
    container.add(_content = new SimplePanel());
    _content.setStyleName("ContentPanelContent");

    // back to discussions button hidden by default
    container.add(_backButton = new Label(_msgs.detailBackToDiscussions()));
    _backButton.setVisible(false);
    _backButton.addStyleName("actionLabel");
    _backButton.addStyleName("ContentBackButton");
    ClickHandler backClick =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            showDiscussions();
          }
        };
    _backButton.addClickHandler(backClick);
  }
Exemplo n.º 6
0
 protected void displayThanks() {
   clear();
   SmartTable box = new SmartTable(0, 10);
   box.setText(0, 0, _msgs.configThanks());
   box.setWidget(
       1, 0, MsoyUI.createButton(MsoyUI.MEDIUM_THIN, _msgs.configGoBack(), NaviUtil.onGoBack()));
   box.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasAlignment.ALIGN_CENTER);
   add(box);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
0
 public FBArcadePanel() {
   super("fbarcade", "fixed");
   add(MsoyUI.createNowLoading());
   _gamesvc.loadArcadeData(
       ArcadeData.Portal.FACEBOOK,
       new PageCallback<ArcadeData>(this) {
         public void onSuccess(ArcadeData data) {
           init(data);
         }
       });
 }
Exemplo n.º 9
0
  protected void grantMedal(final VizMemberName member, final Medal medal) {
    if (medal == null) {
      MsoyUI.error(_msgs.awardMedalsNoMedalChosen());
    }

    _groupsvc.awardMedal(
        member.getId(),
        medal.medalId,
        new InfoCallback<Void>() {
          public void onSuccess(Void result) {
            MsoyUI.info(_msgs.awardMedalsMedalGranted(member.toString(), medal.name));
          }
        });
  }
Exemplo n.º 10
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);
   }
 }
Exemplo n.º 11
0
  protected void displaySearchResults(final List<VizMemberName> members) {
    if (_medals == null) {
      // we need _medals to be valid before we can proceed with this operation.
      _medalsValidCommand =
          new Command() {
            public void execute() {
              displaySearchResults(members);
            }
          };
      return;
    }

    if (members.size() == 0) {
      MsoyUI.info(_msgs.awardMedalsNoMembersFound());
      return;
    }

    for (final VizMemberName member : members) {
      HorizontalPanel row = new HorizontalPanel();
      row.setSpacing(10);
      row.add(MediaUtil.createMediaView(member.getPhoto(), MediaDescSize.HALF_THUMBNAIL_SIZE));
      row.add(Link.create(member.toString(), Pages.PEOPLE, "" + member.getId()));
      // TODO: this will be really inefficient for groups that have a ton of Medals.  This
      // UI should contain only one drop down if at all possible.
      final ListBox awardDrop = createDropDown();
      row.add(awardDrop);
      row.add(
          new Button(
              _msgs.awardMedalsAward(),
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  int selected = Math.max(0, awardDrop.getSelectedIndex());
                  Medal medal =
                      awardDrop.getItemCount() < 0
                          ? null
                          : _medalMap.get(awardDrop.getValue(selected));
                  grantMedal(member, medal);
                }
              }));
      add(row);
    }
  }
Exemplo n.º 12
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));
            }
          });
    }
  }
Exemplo n.º 13
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();
    }
  }
Exemplo n.º 14
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);
          }
        });
  }
Exemplo n.º 15
0
  protected void init(final GameData data) {
    clear();

    SmartTable header = new SmartTable("Header", 0, 10);
    header.setText(0, 0, data.info.name, 1, "Title");
    header.setWidget(0, 1, MsoyUI.createHTML(_msgs.egTip(), null), 1, "Tip");
    Button delete = new Button(_msgs.egDelete());
    header.setWidget(0, 2, delete);
    header.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasAlignment.ALIGN_RIGHT);
    add(header);

    // wire up the delete button
    new ClickCallback<Void>(delete, _msgs.egDeleteConfirm()) {
      @Override
      protected boolean callService() {
        _gamesvc.deleteGame(data.info.gameId, this);
        return true;
      }

      @Override
      protected boolean gotResult(Void result) {
        Link.go(Pages.EDGAMES, "m");
        return true;
      }
    };

    // add our giant tab list of doom
    add(
        _tabs =
            new NaviTabPanel(Pages.EDGAMES) {
              protected Args getTabArgs(int tabIdx) {
                return Args.compose("e", _gameId, tabIdx);
              }
            });

    _tabs.add(
        new LazyPanel() {
          protected Widget createWidget() {
            return new InfoEditorPanel(data);
          }
        },
        _msgs.egTabInfo());
    _tabs.add(
        new LazyPanel() {
          protected Widget createWidget() {
            return new CodeEditorPanel(data.info, data.devCode);
          }
        },
        _msgs.egTabCode());
    _tabs.add(
        new LazyPanel() {
          protected Widget createWidget() {
            return new PublishPanel(data);
          }

          @Override
          public void setVisible(boolean visible) {
            if (!visible) {
              setWidget(null); // clear out our panel when we change tabs
            }
            super.setVisible(visible);
          }
        },
        _msgs.egTabPublish());
    _tabs.add(
        new LazyPanel() {
          protected Widget createWidget() {
            return new FacebookGameInfoEditorPanel(data.facebook);
          }
        },
        _msgs.egTabFacebook());
    // NOTE: if you add a tab here, you have to adjust StuffPage.PRE_ITEM_TABS

    for (final MsoyItemType type : GameItem.TYPES) {
      _tabs.add(
          new LazyPanel() {
            protected Widget createWidget() {
              return new GameItemEditorPanel(data.info.gameId, type);
            }
          },
          _dmsgs.xlateItemsType(type));
    }
  }
Exemplo n.º 16
0
 public EditGamePanel() {
   setStyleName("editGame");
   add(MsoyUI.createNowLoading());
 }