Project

General

Profile

« Previous | Next » 

Revision 7654a99d

Added by Leszek Koltunski over 1 year ago

Purchase Pane: further progress.

View differences:

src/main/java/org/distorted/purchase/PurchaseScreenPane.java
25 25
import org.distorted.library.main.DistortedScreen;
26 26
import org.distorted.main.R;
27 27
import org.distorted.objectlib.json.JsonReader;
28
import org.distorted.objectlib.main.ObjectControl;
28 29
import org.distorted.objects.RubikObject;
29 30
import org.distorted.objects.RubikObjectList;
30 31
import org.distorted.overlays.DataStars;
32
import org.distorted.overlays.ListenerOverlay;
31 33
import org.distorted.overlays.OverlayStars;
32 34

  
33 35
import java.io.InputStream;
36
import java.lang.ref.WeakReference;
34 37

  
35 38
///////////////////////////////////////////////////////////////////////////////////////////////////
36 39

  
37
public class PurchaseScreenPane
40
public class PurchaseScreenPane implements ListenerOverlay
38 41
{
39 42
  public static final int UNLOCK_ALL_PRICE = 500;
40 43

  
......
51 54
  public  static final float PADDING_RATIO = 0.025f;
52 55
  private static final float TEXT_RATIO    = 0.050f;
53 56

  
57
  private final WeakReference<PurchaseActivity> mAct;
54 58
  private RubikObject mObject;
55 59

  
56 60
///////////////////////////////////////////////////////////////////////////////////////////////////
......
84 88

  
85 89
  private void showSuccess(PurchaseActivity act, RubikObject object)
86 90
    {
91
    act.blockUI();
87 92
    RubikScores scores = RubikScores.getInstance();
88 93
    int totStars = scores.getNumStars();
89 94
    int price = object==null ? UNLOCK_ALL_PRICE:object.getPrice();
90 95
    PurchaseRenderer renderer = act.getRenderer();
91 96
    DistortedScreen screen = renderer.getScreen();
92 97
    OverlayStars stars = new OverlayStars();
93
    DataStars data = new DataStars(totStars,-price,act.getResources());
94
    stars.startOverlay(screen,null,data);
98
    DataStars data = new DataStars(totStars+price,-price,act.getResources());
99
    stars.startOverlay(screen,this,data);
95 100
    }
96 101

  
97 102
///////////////////////////////////////////////////////////////////////////////////////////////////
......
220 225

  
221 226
  PurchaseScreenPane(final PurchaseActivity act)
222 227
    {
228
    mAct = new WeakReference<>(act);
223 229
    int width = act.getScreenWidthInPixels();
224 230
    float textSize = width*TEXT_RATIO;
225 231
    int margin = (int)(width*PADDING_RATIO);
......
267 273

  
268 274
    setUpButtons(act,oneLayout,allLayout);
269 275
    }
276

  
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

  
279
  public void overlayFinished(long id)
280
    {
281
    PurchaseActivity act = mAct.get();
282

  
283
    if( act!=null )
284
      {
285
      String upperName = mObject.getUpperName();
286
      int ordinal = RubikObjectList.getOrdinal(upperName);
287
      RubikObjectList.setCurrObject(ordinal);
288
      ObjectControl control = act.getControl();
289
      if( control!=null ) control.unblockEverything();
290
      act.finish();
291
      }
292
    }
270 293
}

Also available in: Unified diff