<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] Setting Path Values for Android</title>
		<link>http://www.allegro.cc/forums/view/613223</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 05 Sep 2013 22:08:48 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello. I&#39;m having issues with finding paths in an Android project of mine. Here&#39;s my path-setting function:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> SetResourcePath<span class="k2">(</span><span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>k_resources_directory<span class="k2">)</span> <span class="k2">{</span>

    ALLEGRO_PATH <span class="k3">*</span>path <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_standard_path"><span class="a">al_get_standard_path</span></a><span class="k2">(</span>ALLEGRO_RESOURCES_PATH<span class="k2">)</span><span class="k2">;</span>

    <a href="http://www.allegro.cc/manual/al_append_path_component"><span class="a">al_append_path_component</span></a><span class="k2">(</span>path, k_resources_directory<span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_path_cstr"><span class="a">al_path_cstr</span></a><span class="k2">(</span>path, <span class="s">'/'</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>

    <a href="http://www.allegro.cc/manual/al_destroy_path"><span class="a">al_destroy_path</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

The directory of my resources is ./assets, which I call by SetResourcePath(&quot;assets&quot;). Well, it&#39;s not working on Android. Is there any particular reason as to why this is?</p><p>Also, I can&#39;t seem to get my Android project to compile with my own directories. For example, I want to have a &quot;potatoes&quot; directory, so I throw the directory into the project, but it doesn&#39;t compile with it. It does, however, compile with an &quot;assets&quot; directory. Why is that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Eric Johnson)</author>
		<pubDate>Thu, 05 Sep 2013 21:35:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, its been a while since i last played with those things, but I&#39;m not sure you can get to the actual app resources with ALLEGRO_RESOURCES_PATH. Try ALLEGRO_USER_DATA_PATH.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/613223/989650#target">Sheegoth</a> said:</div><div class="quote"><p>Also, I can&#39;t seem to get my Android project to compile with my own directories. For example, I want to have a &quot;potatoes&quot; directory, so I throw the directory into the project, but it doesn&#39;t compile with it. It does, however, compile with an &quot;assets&quot; directory. Why is that?</p></div></div><p>I think its because Android has a specific package layout that you need to stick to.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 05 Sep 2013 21:39:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><b>Edit (13.09.06 at 13:43 PST)</b><br />I believe I&#39;ve found a solution, but have met yet another obstacle. Please view <a href="https://www.allegro.cc/forums/thread/613235">this</a> forum post. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p><s>

<b>Edit (13.09.06 at 16:00 PST)</b>
In Ubuntu, the sources can be procured just fine, but when thrown onto Android in an APK, it can&#39;t seem to find the assets directory. Below is some code I threw together quite quickly to swift through the file-path options and to stop upon finally procuring the image file. It always lands on ALLEGRO_RESOURCES_PATH when in Ubuntu, but never finds it at all when in an APK. Thoughts? :o

&lt;code name=&quot;LoadResources&quot;&gt;
// ===========================================================================
// Procure and initate game-related resources and objects
// ===========================================================================
void Thaed::LoadResources(void) {

    while (true) {

        static int s_i = 0;

        // Attempt to procure the file in question
        b = al_load_bitmap(&quot;player.png&quot;);

        if (!b) {

            // Cycle through the next path phase if bitmap wasn&#39;t procured
            BombuSetResourceDirectory(s_i, &quot;assets&quot;);
        }
        else break; // Bitmap was procured, so end the loop

        cout &lt;&lt; &quot;Checking &quot; &lt;&lt; s_i &lt;&lt; &quot;...\n&quot;;

        ++s_i;

        if (s_i &gt; 5) break; // We&#39;re only checking six paths
    }
}
&lt;/code&gt;

&lt;code name=&quot;BombuSetResourceDirectory&quot;&gt;
// ===========================================================================
// Redirect the current working directory to the resource directory
// ===========================================================================
void Bombu::BombuSetResourceDirectory(const int k_what, const char *k_directory) {

    ALLEGRO_PATH *path;

    switch (k_what) {

        case 0: path = al_get_standard_path(ALLEGRO_USER_HOME_PATH); break;

        case 1: path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH); break;

        case 2: path = al_get_standard_path(ALLEGRO_USER_DOCUMENTS_PATH); break;

        case 3: path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); break;

        case 4: path = al_get_standard_path(ALLEGRO_EXENAME_PATH); break;

        case 5: path = al_get_standard_path(ALLEGRO_USER_DATA_PATH); break;

        default: path = al_get_standard_path(ALLEGRO_USER_HOME_PATH); break;
    }

    // Reroute the current working directory
    al_append_path_component(path, k_directory);
    al_change_directory(al_path_cstr(path, &#39;/&#39;));

    cout &lt;&lt; al_path_cstr(path, &#39;/&#39;) &lt;&lt; endl;

    // Remove path from memory now that the directories are in working order
    al_destroy_path(path);
}
&lt;/code&gt;

</s>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Eric Johnson)</author>
		<pubDate>Thu, 05 Sep 2013 22:08:48 +0000</pubDate>
	</item>
</rss>
