예제 #1
0
  /**
   * @param saveName
   * @param doneCb (error) called when operation is done
   */
  public void saveAppData(Callback1<String> doneCb) {
    log.info("saving application config from game storage");

    Object data = JSObjectAdapter.$js("{}");
    ListUtil.forEachArrayValue(
        appHandlers,
        (index, appHandler) -> {
          Object handlerData = JSObjectAdapter.$js("{}");
          appHandler.onAppSave(handlerData);
          JSObjectAdapter.$put(data, ClassUtil.getClassName(appHandler), handlerData);
        });

    pm.set(CONFIG_APP_JSON, data, (err, savedData) -> doneCb.$invoke(err));
  }
예제 #2
0
  /**
   * @param saveName
   * @param doneCb (error) called when operation is done
   */
  public void loadAppData(Callback1<String> doneCb) {
    pm.get(
        CONFIG_APP_JSON,
        (err, data) -> {
          if (NullUtil.isPresent(data)) {
            log.info("loading application config from game storage");

            ListUtil.forEachArrayValue(
                appHandlers,
                (index, appHandler) -> {
                  Object handlerData =
                      JSObjectAdapter.$get(data, ClassUtil.getClassName(appHandler));
                  if (NullUtil.isPresent(handlerData)) {
                    appHandler.onAppLoad(handlerData);
                  }
                });

          } else {
            log.info("there is no application config in the game storage yet");
          }
          doneCb.$invoke("");
        });
  }