Skip to content

Commit

Permalink
Add another story to initial list. Add user interface controls to set…
Browse files Browse the repository at this point in the history
… Thunderword activity, reworked activitycode parameter.
  • Loading branch information
WakeRealityDev committed Feb 27, 2017
1 parent 53b1dd8 commit 4569fa1
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 9 deletions.
33 changes: 31 additions & 2 deletions app/src/main/java/com/yrek/incant/StoryDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import android.app.Activity;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.style.TextAppearanceSpan;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -25,6 +29,8 @@ public class StoryDetails extends Activity {
private TextAppearanceSpan titleStyle;
private TextAppearanceSpan authorStyle;
private TextAppearanceSpan headlineStyle;
private boolean launchInterruptStory = true;
protected int selectedLaunchActivity = 0;
protected static AtomicInteger launchToken = new AtomicInteger(0);

@Override
Expand Down Expand Up @@ -176,13 +182,32 @@ public void run() {
}
intent.putExtra("path", exportStoryDataFile.getPath());
int myLaunchToken = launchToken.incrementAndGet();
Log.i(TAG, "path " + exportStoryDataFile.getPath() + " sender " + BuildConfig.APPLICATION_ID + " launchToken " + myLaunchToken);
intent.putExtra("activity", 1 /* Bidirectional Scrolling Activity */);
Log.i(TAG, "path " + exportStoryDataFile.getPath() + " sender " + BuildConfig.APPLICATION_ID + " launchToken " + myLaunchToken + " selectedLaunchActivity " + selectedLaunchActivity);
// Set default value.
if (selectedLaunchActivity == 0) {
selectedLaunchActivity = 1; /* Bidirectional Scrolling Activity */
}
intent.putExtra("activitycode", selectedLaunchActivity);
intent.putExtra("interrupt", launchInterruptStory);
intent.putExtra("launchtoken", "A" + myLaunchToken);
sendBroadcast(intent);
}
});

final TypedArray selectedActivityValues = getResources().obtainTypedArray(R.array.thunderword_activity_values);

((Spinner) findViewById(R.id.external_provider_activity)).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selectedLaunchActivity = selectedActivityValues.getInt(position, -1);
}

@Override
public void onNothingSelected(AdapterView<?> parent) {
selectedLaunchActivity = 0;
}
});

int outEngine = story.isZcode(StoryDetails.this) ? R.string.play_zcode : R.string.play_glulx;
((TextView) findViewById(R.id.play_text)).setText(outEngine);
if (story.getCoverImageFile(StoryDetails.this).exists()) {
Expand Down Expand Up @@ -260,4 +285,8 @@ private SpannableStringBuilder makeAuthor() {
sb.setSpan(authorStyle, start, sb.length(), 0);
return sb;
}

public void onProviderInterruptClicked(View view) {
launchInterruptStory = ((CheckBox) view).isChecked();
}
}
41 changes: 34 additions & 7 deletions app/src/main/res/layout/story_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,40 @@
android:text="@string/play_via_external_engine_provider"
android:id="@+id/play_via_external_engine_provider"
/>
<TextView
android:layout_column="2"
android:layout_span="1"
android:id="@+id/play_via_external_engine_provider_text"
android:scrollHorizontally="true"
android:ellipsize="marquee"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Spinner
android:id="@+id/external_provider_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/thunderword_activity_names"
android:entryValues="@array/thunderword_activity_values"
/>
<TextView
android:id="@+id/external_provider_activity_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/external_provider_activity"
android:layout_alignBaseline="@+id/external_provider_activity"
android:paddingLeft="4dp"
android:text="Activity"
/>
<CheckBox android:id="@+id/external_provider_noprompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:paddingLeft="2dp"
android:paddingRight="3dp"
android:text="@string/external_provider_noprompt"
android:background="#E8FFFF"
android:layout_toRightOf="@+id/external_provider_activity_label"
android:layout_alignBaseline="@+id/external_provider_activity"
android:onClick="onProviderInterruptClicked"
android:checked="true"
/>
</RelativeLayout>
</TableRow>
<TableRow>
<RelativeLayout
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Value 0 means headless, and we aren't going to give the user that choice in this app's GUI. -->
<string-array name="thunderword_activity_names">
<item>Bi-directional scrolling</item>
<item>Scrolling</item>
<item>Flexible (incomplete)</item>
<item>Two-Window classic</item>
<item>5 (future)</item>
<item>6 (future)</item>
<item>7 (future)</item>
<item>8 (future)</item>
</string-array>
<string-array name="thunderword_activity_values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
</string-array>

</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/values/initial_story_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@
<item/>
<item/>

<item>Brain Guzzlers from Beyond!</item>
<item>Steph Cherrywell</item>
<item>Humor, 2015</item>
<item>You are Bonnie Noodleman, Ordinary Well-Adjusted Teen-Ager, on an ordinary well-adjusted drive up Make-Out Mountain--until some gooey monstrosity from beyond the stars guzzles your boyfriend\'s brains clean out of his head! Jeepers, what a pickle! Can you convince the townsfolk you\'re not koo-koo, or is your thinker next on the alien menu? Explore beautiful Canyonville, New Mexico, at the height of the 1959 Pine Nut Days festival, interact with a full cast of NPCs, perform beat poetry, tamper with baked goods, use hideously powerful space weapons to win cheap carnival trinkets, and try to avoid getting a Reputation! </item>
<item>http://mirror.ifarchive.org/if-archive/games/glulx/Brain_Guzzlers_from_Beyond%21.gblorb</item>
<item/>
<item/>

<item>Glulxercise</item>
<item>Andrew Plotkin</item>
<item>A Glulx interpreter unit test</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@
<string name="main_intro_message1_styled"></string>
<string name="main_intro_button_label0">[ Hide this message ]</string>
<string name="action_onscreen_debug">Show Debug</string>
<string name="external_provider_noprompt">Interrupt story</string>
</resources>

0 comments on commit 4569fa1

Please # to comment.