diff --git a/android/app/build.gradle b/android/app/build.gradle index 97267258e2..7a6f34b58b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,6 +98,13 @@ android { dependencies { implementation 'com.google.vr:sdk-audio:1.80.0' implementation 'com.google.vr:sdk-base:1.80.0' + + + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.android.support:design:26.1.0' + implementation 'com.android.support:appcompat-v7:26.1.0' + compile 'com.android.support:recyclerview-v7:26.1.0' + implementation fileTree(include: ['*.jar'], dir: 'libs') } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b3a8c87649..ed9caee58b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -38,6 +38,17 @@ --> + + + + + + diff --git a/android/app/src/main/assets/hifi_domains.json b/android/app/src/main/assets/hifi_domains.json new file mode 100644 index 0000000000..a63ef7b6aa --- /dev/null +++ b/android/app/src/main/assets/hifi_domains.json @@ -0,0 +1,24 @@ +{ + "hifi_domains" : [ + { + "name": "Your last location", + "url": "", + "thumbnail": "" + }, + { + "name": "dev-mobile-master", + "url": "hifi://dev-mobile-master", + "thumbnail": "" + }, + { + "name": "dev-mobile", + "url": "hifi://dev-mobile", + "thumbnail": "" + }, + { + "name": "dev-welcome", + "url": "hifi://dev-welcome", + "thumbnail": "" + } + ] +} \ No newline at end of file diff --git a/android/app/src/main/cpp/native.cpp b/android/app/src/main/cpp/native.cpp index 13daf4c471..facf6bd4bd 100644 --- a/android/app/src/main/cpp/native.cpp +++ b/android/app/src/main/cpp/native.cpp @@ -17,6 +17,12 @@ #include #include +#include + +#include +#include "AndroidHelper.h" + +QAndroidJniObject __activity; void tempMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { if (!message.isEmpty()) { @@ -138,9 +144,26 @@ extern "C" { JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) { qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId(); g_assetManager = AAssetManager_fromJava(env, asset_mgr); + __activity = QAndroidJniObject(instance); auto oldMessageHandler = qInstallMessageHandler(tempMessageHandler); unpackAndroidAssets(); qInstallMessageHandler(oldMessageHandler); + + QObject::connect(&AndroidHelper::instance(), &AndroidHelper::androidActivityRequested, [](const QString& a) { + QAndroidJniObject string = QAndroidJniObject::fromString(a); + __activity.callMethod("openAndroidActivity", "(Ljava/lang/String;)V", string.object()); + }); +} + +JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnDestroy(JNIEnv* env, jobject obj) { + QObject::disconnect(&AndroidHelper::instance(), &AndroidHelper::androidActivityRequested, + nullptr, nullptr); + +} + +JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGotoUrl(JNIEnv* env, jobject obj, jstring url) { + QAndroidJniObject jniUrl("java/lang/String", "(Ljava/lang/String;)V", url); + DependencyManager::get()->handleLookupString(jniUrl.toString()); } JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnPause(JNIEnv* env, jobject obj) { @@ -155,6 +178,30 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnExit qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId(); } +JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGoBackFromAndroidActivity(JNIEnv *env, jobject instance) { + AndroidHelper::instance().goBackFromAndroidActivity(); } +// HifiUtils +JNIEXPORT jstring JNICALL Java_io_highfidelity_hifiinterface_HifiUtils_getCurrentAddress(JNIEnv *env, jobject instance) { + QSharedPointer addressManager = DependencyManager::get(); + if (!addressManager) { + return env->NewString(nullptr, 0); + } + QString str; + if (!addressManager->getPlaceName().isEmpty()) { + str = addressManager->getPlaceName(); + } else if (!addressManager->getHost().isEmpty()) { + str = addressManager->getHost(); + } + + QRegExp pathRegEx("(\\/[^\\/]+)"); + if (!addressManager->currentPath().isEmpty() && addressManager->currentPath().contains(pathRegEx) && pathRegEx.matchedLength() > 0) { + str += pathRegEx.cap(0); + } + + return env->NewStringUTF(str.toLatin1().data()); +} + +} diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/GotoActivity.java b/android/app/src/main/java/io/highfidelity/hifiinterface/GotoActivity.java new file mode 100644 index 0000000000..995e64c2a5 --- /dev/null +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/GotoActivity.java @@ -0,0 +1,94 @@ +package io.highfidelity.hifiinterface; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.AppCompatButton; +import android.support.v7.widget.Toolbar; +import android.view.KeyEvent; +import android.view.MenuItem; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.EditText; + +import java.net.URI; +import java.net.URISyntaxException; + +public class GotoActivity extends AppCompatActivity { + + public static final String PARAM_DOMAIN_URL = "domain_url"; + + private EditText mUrlEditText; + private AppCompatButton mGoBtn; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_goto); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setTitleTextAppearance(this, R.style.HomeActionBarTitleStyle); + setSupportActionBar(toolbar); + + ActionBar actionbar = getSupportActionBar(); + actionbar.setDisplayHomeAsUpEnabled(true); + + mUrlEditText = (EditText) findViewById(R.id.url_text); + mUrlEditText.setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View view, int i, KeyEvent keyEvent) { + if (i == KeyEvent.KEYCODE_ENTER) { + actionGo(); + return true; + } + return false; + } + }); + + mUrlEditText.setText(HifiUtils.getInstance().getCurrentAddress()); + + mGoBtn = (AppCompatButton) findViewById(R.id.go_btn); + + mGoBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + actionGo(); + } + }); + } + + private void actionGo() { + String urlString = mUrlEditText.getText().toString(); + if (!urlString.trim().isEmpty()) { + URI uri; + try { + uri = new URI(urlString); + } catch (URISyntaxException e) { + return; + } + if (uri.getScheme() == null || uri.getScheme().isEmpty()) { + urlString = "hifi://" + urlString; + } + + Intent intent = new Intent(); + intent.putExtra(GotoActivity.PARAM_DOMAIN_URL, urlString); + setResult(RESULT_OK, intent); + finish(); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + switch (id) { + case android.R.id.home: + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/HifiUtils.java b/android/app/src/main/java/io/highfidelity/hifiinterface/HifiUtils.java new file mode 100644 index 0000000000..15d716548f --- /dev/null +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/HifiUtils.java @@ -0,0 +1,23 @@ +package io.highfidelity.hifiinterface; + +/** + * Created by Gabriel Calero & Cristian Duarte on 4/13/18. + */ + +public class HifiUtils { + + private static HifiUtils instance; + + private HifiUtils() { + } + + public static HifiUtils getInstance() { + if (instance == null) { + instance = new HifiUtils(); + } + return instance; + } + + public native String getCurrentAddress(); + +} diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/HomeActivity.java b/android/app/src/main/java/io/highfidelity/hifiinterface/HomeActivity.java new file mode 100644 index 0000000000..611c8f50cc --- /dev/null +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/HomeActivity.java @@ -0,0 +1,220 @@ +package io.highfidelity.hifiinterface; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.graphics.Color; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.design.widget.NavigationView; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.SearchView; +import android.widget.TabHost; +import android.widget.TabWidget; +import android.widget.TextView; + +import io.highfidelity.hifiinterface.QtPreloader.QtPreloader; +import io.highfidelity.hifiinterface.view.DomainAdapter; + +public class HomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + /** + * Set this intent extra param to NOT start a new InterfaceActivity after a domain is selected" + */ + public static final String PARAM_NOT_START_INTERFACE_ACTIVITY = "not_start_interface_activity"; + + public static final int ENTER_DOMAIN_URL = 1; + + private DomainAdapter domainAdapter; + private DrawerLayout mDrawerLayout; + private ProgressDialog mDialog; + private NavigationView mNavigationView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + toolbar.setTitleTextAppearance(this, R.style.HomeActionBarTitleStyle); + setSupportActionBar(toolbar); + + ActionBar actionbar = getSupportActionBar(); + actionbar.setDisplayHomeAsUpEnabled(true); + actionbar.setHomeAsUpIndicator(R.drawable.ic_menu); + + mDrawerLayout = findViewById(R.id.drawer_layout); + + mNavigationView = (NavigationView) findViewById(R.id.nav_view); + mNavigationView.setNavigationItemSelectedListener(this); + + TabHost tabs = (TabHost)findViewById(R.id.tabhost); + tabs.setup(); + + TabHost.TabSpec spec=tabs.newTabSpec("featured"); + spec.setContent(R.id.featured); + spec.setIndicator(getString(R.string.featured)); + tabs.addTab(spec); + + spec = tabs.newTabSpec("popular"); + spec.setContent(R.id.popular); + spec.setIndicator(getString(R.string.popular)); + tabs.addTab(spec); + + spec = tabs.newTabSpec("bookmarks"); + spec.setContent(R.id.bookmarks); + spec.setIndicator(getString(R.string.bookmarks)); + tabs.addTab(spec); + + tabs.setCurrentTab(0); + + TabWidget tabwidget=tabs.getTabWidget(); + for(int i=0; i libraryList = new ArrayList<>(); + String localPrefix = m_context.getApplicationInfo().dataDir + "/"; + String pluginsPrefix = localPrefix + "qt-reserved-files/"; + cleanOldCacheIfNecessary(localPrefix, pluginsPrefix); + extractBundledPluginsAndImports(pluginsPrefix); + + for (String lib : m_qtLibs) { + libraryList.add(localPrefix + "lib/lib" + lib + ".so"); + } + + if (m_contextInfo.metaData.containsKey("android.app.load_local_libs")) { + String[] extraLibs = m_contextInfo.metaData.getString("android.app.load_local_libs").split(":"); + for (String lib : extraLibs) { + if (lib.length() > 0) { + if (lib.startsWith("lib/")) { + libraryList.add(localPrefix + lib); + } else { + libraryList.add(pluginsPrefix + lib); + } + } + } + } + + Bundle loaderParams = new Bundle(); + loaderParams.putString(DEX_PATH_KEY, new String()); + + loaderParams.putStringArrayList(NATIVE_LIBRARIES_KEY, libraryList); + + loaderParams.putString(ENVIRONMENT_VARIABLES_KEY, ENVIRONMENT_VARIABLES + + "\tQML2_IMPORT_PATH=" + pluginsPrefix + "/qml" + + "\tQML_IMPORT_PATH=" + pluginsPrefix + "/imports" + + "\tQT_PLUGIN_PATH=" + pluginsPrefix + "/plugins"); + + + // add all bundled Qt libs to loader params + ArrayList libs = new ArrayList<>(); + + String libName = m_contextInfo.metaData.getString("android.app.lib_name"); + loaderParams.putString(MAIN_LIBRARY_KEY, libName); //main library contains main() function + loaderParams.putStringArrayList(BUNDLED_LIBRARIES_KEY, libs); + + // load and start QtLoader class + DexClassLoader classLoader = new DexClassLoader(loaderParams.getString(DEX_PATH_KEY), // .jar/.apk files + m_context.getDir("outdex", Context.MODE_PRIVATE).getAbsolutePath(), // directory where optimized DEX files should be written. + loaderParams.containsKey(LIB_PATH_KEY) ? loaderParams.getString(LIB_PATH_KEY) : null, // libs folder (if exists) + m_context.getClassLoader()); // parent loader + + Class loaderClass = classLoader.loadClass(loaderClassName()); // load QtLoader class + Object qtLoader = loaderClass.newInstance(); // create an instance + Method prepareAppMethod = qtLoader.getClass().getMethod("loadApplication", + contextClassName(), + ClassLoader.class, + Bundle.class); + prepareAppMethod.invoke(qtLoader, m_context, classLoader, loaderParams); + + // now load the application library so it's accessible from this class loader + if (libName != null) { + System.loadLibrary(libName); + } + } catch (Exception e) { + Log.e(QtApplication.QtTAG, "Error pre-loading HiFi Qt app", e); + } + } + + protected String loaderClassName() { + return "org.qtproject.qt5.android.QtActivityDelegate"; + } + + protected Class contextClassName() { + return android.app.Activity.class; + } + + + private void deleteRecursively(File directory) { + File[] files = directory.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + deleteRecursively(file); + } else { + file.delete(); + } + } + + directory.delete(); + } + } + + private void cleanOldCacheIfNecessary(String oldLocalPrefix, String localPrefix) { + File newCache = new File(localPrefix); + if (!newCache.exists()) { + { + File oldPluginsCache = new File(oldLocalPrefix + "plugins/"); + if (oldPluginsCache.exists() && oldPluginsCache.isDirectory()) { + deleteRecursively(oldPluginsCache); + } + } + + { + File oldImportsCache = new File(oldLocalPrefix + "imports/"); + if (oldImportsCache.exists() && oldImportsCache.isDirectory()) { + deleteRecursively(oldImportsCache); + } + } + + { + File oldQmlCache = new File(oldLocalPrefix + "qml/"); + if (oldQmlCache.exists() && oldQmlCache.isDirectory()) { + deleteRecursively(oldQmlCache); + } + } + } + } + + static private void copyFile(InputStream inputStream, OutputStream outputStream) + throws IOException { + byte[] buffer = new byte[BUFFER_SIZE]; + + int count; + while ((count = inputStream.read(buffer)) > 0) { + outputStream.write(buffer, 0, count); + } + } + + private void copyAsset(String source, String destination) + throws IOException { + // Already exists, we don't have to do anything + File destinationFile = new File(destination); + if (destinationFile.exists()) { + return; + } + + File parentDirectory = destinationFile.getParentFile(); + if (!parentDirectory.exists()) { + parentDirectory.mkdirs(); + } + + destinationFile.createNewFile(); + + AssetManager assetsManager = m_context.getAssets(); + InputStream inputStream = assetsManager.open(source); + OutputStream outputStream = new FileOutputStream(destinationFile); + copyFile(inputStream, outputStream); + + inputStream.close(); + outputStream.close(); + } + + private static void createBundledBinary(String source, String destination) + throws IOException { + // Already exists, we don't have to do anything + File destinationFile = new File(destination); + if (destinationFile.exists()) { + return; + } + + File parentDirectory = destinationFile.getParentFile(); + if (!parentDirectory.exists()) { + parentDirectory.mkdirs(); + } + + destinationFile.createNewFile(); + + InputStream inputStream = new FileInputStream(source); + OutputStream outputStream = new FileOutputStream(destinationFile); + copyFile(inputStream, outputStream); + + inputStream.close(); + outputStream.close(); + } + + private boolean cleanCacheIfNecessary(String pluginsPrefix, long packageVersion) { + File versionFile = new File(pluginsPrefix + "cache.version"); + + long cacheVersion = 0; + if (versionFile.exists() && versionFile.canRead()) { + try { + DataInputStream inputStream = new DataInputStream(new FileInputStream(versionFile)); + cacheVersion = inputStream.readLong(); + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (cacheVersion != packageVersion) { + deleteRecursively(new File(pluginsPrefix)); + return true; + } else { + return false; + } + } + + private void extractBundledPluginsAndImports(String pluginsPrefix) throws IOException { + String libsDir = m_context.getApplicationInfo().nativeLibraryDir + "/"; + long packageVersion = -1; + try { + PackageInfo packageInfo = m_context.getPackageManager().getPackageInfo(m_context.getPackageName(), 0); + packageVersion = packageInfo.lastUpdateTime; + } catch (Exception e) { + e.printStackTrace(); + } + + + if (!cleanCacheIfNecessary(pluginsPrefix, packageVersion)) { + return; + } + + { + File versionFile = new File(pluginsPrefix + "cache.version"); + + File parentDirectory = versionFile.getParentFile(); + if (!parentDirectory.exists()) { + parentDirectory.mkdirs(); + } + + versionFile.createNewFile(); + + DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(versionFile)); + outputStream.writeLong(packageVersion); + outputStream.close(); + } + + { + String key = BUNDLED_IN_LIB_RESOURCE_ID_KEY; + if (m_contextInfo.metaData.containsKey(key)) { + String[] list = m_context.getResources().getStringArray(m_contextInfo.metaData.getInt(key)); + + for (String bundledImportBinary : list) { + String[] split = bundledImportBinary.split(":"); + String sourceFileName = libsDir + split[0]; + String destinationFileName = pluginsPrefix + split[1]; + createBundledBinary(sourceFileName, destinationFileName); + } + } + } + + { + String key = BUNDLED_IN_ASSETS_RESOURCE_ID_KEY; + if (m_contextInfo.metaData.containsKey(key)) { + String[] list = m_context.getResources().getStringArray(m_contextInfo.metaData.getInt(key)); + + for (String fileName : list) { + String[] split = fileName.split(":"); + String sourceFileName = split[0]; + String destinationFileName = pluginsPrefix + split[1]; + copyAsset(sourceFileName, destinationFileName); + } + } + + } + } +} diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/view/DomainAdapter.java b/android/app/src/main/java/io/highfidelity/hifiinterface/view/DomainAdapter.java new file mode 100644 index 0000000000..1129ec586f --- /dev/null +++ b/android/app/src/main/java/io/highfidelity/hifiinterface/view/DomainAdapter.java @@ -0,0 +1,131 @@ +package io.highfidelity.hifiinterface.view; + +import android.content.Context; +import android.support.v7.widget.RecyclerView; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import io.highfidelity.hifiinterface.R; + +/** + * Created by Gabriel Calero & Cristian Duarte on 3/20/18. + */ +public class DomainAdapter extends RecyclerView.Adapter { + + private static final java.lang.String DOMAINS_FILE = "hifi_domains.json"; + private static final String TAG = "HiFi Interface"; + private Context mContext; + private LayoutInflater mInflater; + private ItemClickListener mClickListener; + + public class Domain { + public String name; + public String url; + public String thumbnail; + Domain(String name, String url, String thumbnail) { + this.name = name; + this.thumbnail = thumbnail; + this.url = url; + } + } + + // references to our domains + private Domain[] mDomains = {}; + + public DomainAdapter(Context c) { + mContext = c; + this.mInflater = LayoutInflater.from(mContext); + loadDomains(); + } + + private void loadDomains() { + try { + JSONObject json = new JSONObject(loadJSONFromAsset()); + JSONArray hifiDomains = json.getJSONArray("hifi_domains"); + List domains = new ArrayList<>(); + for (int i = 0; i < hifiDomains.length(); i++) { + JSONObject jDomain = hifiDomains.getJSONObject(i); + + String domainName = jDomain.getString("name"); + String domainUrl = jDomain.getString("url"); + String domainThumb = jDomain.getString("thumbnail"); + + domains.add(new Domain(domainName, domainUrl, domainThumb)); + } + mDomains = domains.toArray(mDomains); + } catch (IOException e) { + Log.e(TAG, "Error loading domains from local file", e); + } catch (JSONException e) { + Log.e(TAG, "Error loading domains from local file", e); + } + } + + public String loadJSONFromAsset() throws IOException { + String json = null; + InputStream is = mContext.getAssets().open(DOMAINS_FILE); + int size = is.available(); + byte[] buffer = new byte[size]; + is.read(buffer); + is.close(); + json = new String(buffer, "UTF-8"); + return json; + } + + @Override + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = mInflater.inflate(R.layout.domain_view, parent, false); + return new ViewHolder(view); + } + + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + // TODO + //holder.thumbnail.setImageResource(mDomains[position].thumbnail); + holder.mDomainName.setText(mDomains[position].name); + } + + @Override + public int getItemCount() { + return mDomains.length; + } + + public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + TextView mDomainName; + ImageView mThumbnail; + + ViewHolder(View itemView) { + super(itemView); + mThumbnail = (ImageView) itemView.findViewById(R.id.domainThumbnail); + mDomainName = (TextView) itemView.findViewById(R.id.domainName); + itemView.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + int position = getAdapterPosition(); + if (mClickListener != null) mClickListener.onItemClick(view, position, mDomains[position]); + } + } + + // allows clicks events to be caught + public void setClickListener(ItemClickListener itemClickListener) { + this.mClickListener = itemClickListener; + } + // parent activity will implement this method to respond to click events + public interface ItemClickListener { + void onItemClick(View view, int position, Domain domain); + } +} diff --git a/android/app/src/main/res/drawable/domain_bg.xml b/android/app/src/main/res/drawable/domain_bg.xml new file mode 100644 index 0000000000..d30d6413e1 --- /dev/null +++ b/android/app/src/main/res/drawable/domain_bg.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/drawable/ic_bookmark.xml b/android/app/src/main/res/drawable/ic_bookmark.xml new file mode 100644 index 0000000000..ddf03e340b --- /dev/null +++ b/android/app/src/main/res/drawable/ic_bookmark.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/app/src/main/res/drawable/ic_menu.xml b/android/app/src/main/res/drawable/ic_menu.xml new file mode 100644 index 0000000000..cf37e2a393 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_menu.xml @@ -0,0 +1,9 @@ + + + diff --git a/android/app/src/main/res/drawable/ic_person.xml b/android/app/src/main/res/drawable/ic_person.xml new file mode 100644 index 0000000000..cf57059c77 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_person.xml @@ -0,0 +1,5 @@ + + + + diff --git a/android/app/src/main/res/drawable/ic_share.xml b/android/app/src/main/res/drawable/ic_share.xml new file mode 100644 index 0000000000..91b01694da --- /dev/null +++ b/android/app/src/main/res/drawable/ic_share.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/app/src/main/res/drawable/search_bg.xml b/android/app/src/main/res/drawable/search_bg.xml new file mode 100644 index 0000000000..fd1a9ea42e --- /dev/null +++ b/android/app/src/main/res/drawable/search_bg.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/font/raleway.ttf b/android/app/src/main/res/font/raleway.ttf new file mode 100644 index 0000000000..e570a2d5c3 Binary files /dev/null and b/android/app/src/main/res/font/raleway.ttf differ diff --git a/android/app/src/main/res/font/raleway_bold.xml b/android/app/src/main/res/font/raleway_bold.xml new file mode 100644 index 0000000000..136472c0b3 --- /dev/null +++ b/android/app/src/main/res/font/raleway_bold.xml @@ -0,0 +1,7 @@ + + + diff --git a/android/app/src/main/res/font/raleway_light_italic.xml b/android/app/src/main/res/font/raleway_light_italic.xml new file mode 100644 index 0000000000..4acab05089 --- /dev/null +++ b/android/app/src/main/res/font/raleway_light_italic.xml @@ -0,0 +1,7 @@ + + + diff --git a/android/app/src/main/res/font/raleway_medium.xml b/android/app/src/main/res/font/raleway_medium.xml new file mode 100644 index 0000000000..3894c95b10 --- /dev/null +++ b/android/app/src/main/res/font/raleway_medium.xml @@ -0,0 +1,7 @@ + + + diff --git a/android/app/src/main/res/font/raleway_semibold.xml b/android/app/src/main/res/font/raleway_semibold.xml new file mode 100644 index 0000000000..39cde5a30b --- /dev/null +++ b/android/app/src/main/res/font/raleway_semibold.xml @@ -0,0 +1,7 @@ + + + diff --git a/android/app/src/main/res/layout/activity_goto.xml b/android/app/src/main/res/layout/activity_goto.xml new file mode 100644 index 0000000000..06e1383da5 --- /dev/null +++ b/android/app/src/main/res/layout/activity_goto.xml @@ -0,0 +1,39 @@ + + + + + + + + + diff --git a/android/app/src/main/res/layout/activity_home.xml b/android/app/src/main/res/layout/activity_home.xml new file mode 100644 index 0000000000..144ca84a0f --- /dev/null +++ b/android/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/layout/content_home.xml b/android/app/src/main/res/layout/content_home.xml new file mode 100644 index 0000000000..f25d9d8f7b --- /dev/null +++ b/android/app/src/main/res/layout/content_home.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/layout/domain_view.xml b/android/app/src/main/res/layout/domain_view.xml new file mode 100644 index 0000000000..d0ed2d3a44 --- /dev/null +++ b/android/app/src/main/res/layout/domain_view.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/menu/menu_home.xml b/android/app/src/main/res/menu/menu_home.xml new file mode 100644 index 0000000000..c27233a6c3 --- /dev/null +++ b/android/app/src/main/res/menu/menu_home.xml @@ -0,0 +1,15 @@ + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 344907f039..0325881f1b 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,4 +1,13 @@ #ffffff + #272727 + #000000 + #54D7FD + #1EB5EC + #333333 + #4F4F4F + #33999999 + #212121 + #9e9e9e diff --git a/android/app/src/main/res/values/dimens.xml b/android/app/src/main/res/values/dimens.xml index a9ec657aa9..440adcf6b9 100644 --- a/android/app/src/main/res/values/dimens.xml +++ b/android/app/src/main/res/values/dimens.xml @@ -9,4 +9,6 @@ 14dp 12dp + 12dp + 8dp \ No newline at end of file diff --git a/android/app/src/main/res/values/font_certs.xml b/android/app/src/main/res/values/font_certs.xml new file mode 100644 index 0000000000..d2226ac01c --- /dev/null +++ b/android/app/src/main/res/values/font_certs.xml @@ -0,0 +1,17 @@ + + + + @array/com_google_android_gms_fonts_certs_dev + @array/com_google_android_gms_fonts_certs_prod + + + + MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs= + + + + + MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK + + + diff --git a/android/app/src/main/res/values/preloaded_fonts.xml b/android/app/src/main/res/values/preloaded_fonts.xml new file mode 100644 index 0000000000..6f9d0e424e --- /dev/null +++ b/android/app/src/main/res/values/preloaded_fonts.xml @@ -0,0 +1,9 @@ + + + + @font/raleway_bold + @font/raleway_light_italic + @font/raleway_medium + @font/raleway_semibold + + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index b8080fae0f..6ce0670dd8 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,8 +1,17 @@ Interface + Home + Go To Open in browser Share link Shared a link Share link + FEATURED + POPULAR + BOOKMARKS + Settings + Go To + Type a domain url + Go diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 23fe67f029..55c9b2af11 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,14 +1,41 @@ - - - + + + + + + + @@ -21,5 +48,11 @@ @dimen/text_size_subtitle_material_toolbar + diff --git a/assignment-client/src/assets/AssetServer.h b/assignment-client/src/assets/AssetServer.h index fb88df0171..f83545c25c 100644 --- a/assignment-client/src/assets/AssetServer.h +++ b/assignment-client/src/assets/AssetServer.h @@ -63,7 +63,7 @@ struct AssetMeta { AssetMeta() { } - BakeVersion bakeVersion; + BakeVersion bakeVersion { INITIAL_BAKE_VERSION }; bool failedLastBake { false }; QString lastBakeErrors; }; diff --git a/interface/resources/icons/+android/avatar-a.svg b/interface/resources/icons/+android/avatar-a.svg deleted file mode 100755 index 165b39943e..0000000000 --- a/interface/resources/icons/+android/avatar-a.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - diff --git a/interface/resources/icons/+android/avatar-i.svg b/interface/resources/icons/+android/avatar-i.svg deleted file mode 100755 index c1557487ea..0000000000 --- a/interface/resources/icons/+android/avatar-i.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - diff --git a/interface/resources/icons/+android/backward.svg b/interface/resources/icons/+android/backward.svg old mode 100644 new mode 100755 index ae0893fc66..6b4c560768 --- a/interface/resources/icons/+android/backward.svg +++ b/interface/resources/icons/+android/backward.svg @@ -1,70 +1,13 @@ - - - -image/svg+xml \ No newline at end of file + + + + + + + + diff --git a/interface/resources/icons/+android/goto-a.svg b/interface/resources/icons/+android/goto-a.svg deleted file mode 100755 index 5fb3e52e4c..0000000000 --- a/interface/resources/icons/+android/goto-a.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - diff --git a/interface/resources/icons/+android/goto-i.svg b/interface/resources/icons/+android/goto-i.svg deleted file mode 100644 index 7613beb9e7..0000000000 --- a/interface/resources/icons/+android/goto-i.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - diff --git a/interface/resources/icons/+android/home.svg b/interface/resources/icons/+android/home.svg deleted file mode 100644 index 414c179e79..0000000000 --- a/interface/resources/icons/+android/home.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/interface/resources/icons/+android/login-a.svg b/interface/resources/icons/+android/login-a.svg deleted file mode 100755 index 8a7f097ed7..0000000000 --- a/interface/resources/icons/+android/login-a.svg +++ /dev/null @@ -1,990 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/interface/resources/icons/+android/login-i.svg b/interface/resources/icons/+android/login-i.svg deleted file mode 100755 index 6f011e1d13..0000000000 --- a/interface/resources/icons/+android/login-i.svg +++ /dev/null @@ -1,990 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/interface/resources/icons/+android/mic-unmute-a.svg b/interface/resources/icons/+android/mic-unmute-a.svg old mode 100644 new mode 100755 index bb28dc0f2b..8717636a34 --- a/interface/resources/icons/+android/mic-unmute-a.svg +++ b/interface/resources/icons/+android/mic-unmute-a.svg @@ -1,70 +1,22 @@ - - - -image/svg+xml \ No newline at end of file + + + + + + + + + + + + + + diff --git a/interface/resources/icons/+android/myview-a.svg b/interface/resources/icons/+android/myview-a.svg index 307b559c95..e2c183caf2 100755 --- a/interface/resources/icons/+android/myview-a.svg +++ b/interface/resources/icons/+android/myview-a.svg @@ -1,56 +1,19 @@ - - - -image/svg+xmlAsset 3 \ No newline at end of file + + + + + + + + + + + diff --git a/interface/resources/icons/+android/radar-a.svg b/interface/resources/icons/+android/radar-a.svg deleted file mode 100755 index e4b157f827..0000000000 --- a/interface/resources/icons/+android/radar-a.svg +++ /dev/null @@ -1 +0,0 @@ -Asset 1 \ No newline at end of file diff --git a/interface/resources/icons/+android/radar-hover.svg b/interface/resources/icons/+android/radar-hover.svg deleted file mode 100755 index e4b157f827..0000000000 --- a/interface/resources/icons/+android/radar-hover.svg +++ /dev/null @@ -1 +0,0 @@ -Asset 1 \ No newline at end of file diff --git a/interface/resources/icons/+android/radar-i.svg b/interface/resources/icons/+android/radar-i.svg deleted file mode 100755 index 3994a775d3..0000000000 --- a/interface/resources/icons/+android/radar-i.svg +++ /dev/null @@ -1 +0,0 @@ -Asset 1 \ No newline at end of file diff --git a/interface/resources/images/fly.png b/interface/resources/images/fly.png index 0edfcab21b..b8b96645f8 100644 Binary files a/interface/resources/images/fly.png and b/interface/resources/images/fly.png differ diff --git a/interface/resources/qml/+android/AddressBarDialog.qml b/interface/resources/qml/+android/AddressBarDialog.qml deleted file mode 100644 index 4477d512fc..0000000000 --- a/interface/resources/qml/+android/AddressBarDialog.qml +++ /dev/null @@ -1,232 +0,0 @@ -// -// AddressBarDialog.qml -// -// Created by Austin Davis on 2015/04/14 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import "../controls" -import "../styles" -import "../hifi" as QmlHifi -import "../hifi/toolbars" -import "../styles-uit" as HifiStyles -import "../controls-uit" as HifiControls - -Item { - QmlHifi.HifiConstants { id: android } - - width: parent ? parent.width - android.dimen.windowLessWidth : 0 - height: parent ? parent.height - android.dimen.windowLessHeight : 0 - z: android.dimen.windowZ - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom } - - id: bar - property bool isCursorVisible: false // Override default cursor visibility. - property bool shown: true - - onShownChanged: { - bar.visible = shown; - sendToScript({method: 'shownChanged', params: { shown: shown }}); - if (shown) { - addressLine.text=""; - updateLocationText(addressLine.text.length > 0); - } - } - - function hide() { - shown = false; - sendToScript ({ type: "hide" }); - } - - Component.onCompleted: { - updateLocationText(addressLine.text.length > 0); - } - - HifiConstants { id: hifi } - HifiStyles.HifiConstants { id: hifiStyleConstants } - - signal sendToScript(var message); - - AddressBarDialog { - id: addressBarDialog - } - - - Rectangle { - id: background - gradient: Gradient { - GradientStop { position: 0.0; color: android.color.gradientTop } - GradientStop { position: 1.0; color: android.color.gradientBottom } - } - anchors { - fill: parent - } - - MouseArea { - anchors.fill: parent - } - - QmlHifi.WindowHeader { - id: header - iconSource: "../../../icons/goto-i.svg" - titleText: "GO TO" - } - - HifiStyles.RalewayRegular { - id: notice - text: "YOUR LOCATION" - font.pixelSize: (hifi.fonts.pixelSize * 2.15) * (android.dimen.atLeast1440p ? 1 : .75); - color: "#2CD7FF" - anchors { - bottom: addressBackground.top - bottomMargin: android.dimen.atLeast1440p ? 45 : 34 - left: addressBackground.left - leftMargin: android.dimen.atLeast1440p ? 60 : 45 - } - - } - - property int inputAreaHeight: android.dimen.atLeast1440p ? 210 : 156 - property int inputAreaStep: (height - inputAreaHeight) / 2 - - ToolbarButton { - id: homeButton - y: android.dimen.atLeast1440p ? 280 : 210 - imageURL: "../../icons/home.svg" - onClicked: { - addressBarDialog.loadHome(); - bar.shown = false; - } - anchors { - leftMargin: android.dimen.atLeast1440p ? 75 : 56 - left: parent.left - } - size: android.dimen.atLeast1440p ? 150 : 150//112 - } - - ToolbarButton { - id: backArrow; - imageURL: "../../icons/backward.svg"; - onClicked: addressBarDialog.loadBack(); - anchors { - left: homeButton.right - leftMargin: android.dimen.atLeast1440p ? 70 : 52 - verticalCenter: homeButton.verticalCenter - } - size: android.dimen.atLeast1440p ? 150 : 150 - } - ToolbarButton { - id: forwardArrow; - imageURL: "../../icons/forward.svg"; - onClicked: addressBarDialog.loadForward(); - anchors { - left: backArrow.right - leftMargin: android.dimen.atLeast1440p ? 60 : 45 - verticalCenter: homeButton.verticalCenter - } - size: android.dimen.atLeast1440p ? 150 : 150 - } - - HifiStyles.FiraSansRegular { - id: location; - font.pixelSize: addressLine.font.pixelSize; - color: "lightgray"; - clip: true; - anchors.fill: addressLine; - visible: addressLine.text.length === 0 - z: 1 - } - - Rectangle { - id: addressBackground - x: android.dimen.atLeast1440p ? 780 : 585 - y: android.dimen.atLeast1440p ? 280 : 235 // tweaking by hand - width: android.dimen.atLeast1440p ? 1270 : 952 - height: android.dimen.atLeast1440p ? 150 : 112 - color: "#FFFFFF" - } - - TextInput { - id: addressLine - focus: true - x: android.dimen.atLeast1440p ? 870 : 652 - y: android.dimen.atLeast1440p ? 300 : 245 // tweaking by hand - width: android.dimen.atLeast1440p ? 1200 : 900 - height: android.dimen.atLeast1440p ? 120 : 90 - inputMethodHints: Qt.ImhNoPredictiveText - //helperText: "Hint is here" - font.pixelSize: hifi.fonts.pixelSize * 3.75 - onTextChanged: { - //filterChoicesByText(); - updateLocationText(addressLine.text.length > 0); - if (!isCursorVisible && text.length > 0) { - isCursorVisible = true; - cursorVisible = true; - } - } - - onActiveFocusChanged: { - //cursorVisible = isCursorVisible && focus; - } - } - - - - function toggleOrGo() { - if (addressLine.text !== "") { - addressBarDialog.loadAddress(addressLine.text); - } - bar.shown = false; - } - - Keys.onPressed: { - switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - clearAddressLineTimer.start(); - event.accepted = true - bar.shown = false; - break - case Qt.Key_Enter: - case Qt.Key_Return: - toggleOrGo(); - clearAddressLineTimer.start(); - event.accepted = true - break - } - } - - } - - Timer { - // Delay clearing address line so as to avoid flicker of "not connected" being displayed after entering an address. - id: clearAddressLineTimer - running: false - interval: 100 // ms - repeat: false - onTriggered: { - addressLine.text = ""; - isCursorVisible = false; - } - } - - function updateLocationText(enteringAddress) { - if (enteringAddress) { - notice.text = "Go to a place, @user, path or network address"; - notice.color = "#ffffff"; // hifiStyleConstants.colors.baseGrayHighlight; - location.visible = false; - } else { - notice.text = AddressManager.isConnected ? "YOUR LOCATION:" : "NOT CONNECTED"; - notice.color = AddressManager.isConnected ? hifiStyleConstants.colors.blueHighlight : hifiStyleConstants.colors.redHighlight; - // Display hostname, which includes ip address, localhost, and other non-placenames. - location.text = (AddressManager.placename || AddressManager.hostname || '') + (AddressManager.pathname ? AddressManager.pathname.match(/\/[^\/]+/)[0] : ''); - location.visible = true; - } - } - -} diff --git a/interface/resources/qml/+android/LoginDialog.qml b/interface/resources/qml/+android/LoginDialog.qml deleted file mode 100644 index 567cca9bcf..0000000000 --- a/interface/resources/qml/+android/LoginDialog.qml +++ /dev/null @@ -1,95 +0,0 @@ -// -// LoginDialog.qml -// -// Created by David Rowe on 3 Jun 2015 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 - -import "controls-uit" -import "styles-uit" -import "windows" - -import "LoginDialog" - -ModalWindow { - id: root - HifiConstants { id: hifi } - - objectName: "LoginDialog" - implicitWidth: 1560 - implicitHeight: 450 - y:0 - destroyOnCloseButton: true - destroyOnHidden: true - visible: true - - property string iconText: "" - property int iconSize: 105 - - property string title: "" - property int titleWidth: 0 - - keyboardOverride: true // Disable ModalWindow's keyboard. - - function tryDestroy() { - Controller.setVPadHidden(false); - root.destroy(); - } - - LoginDialog { - id: loginDialog - - Loader { - id: bodyLoader - source: loginDialog.isSteamRunning() ? "LoginDialog/+android/SignInBody.qml" : "LoginDialog/+android/LinkAccountBody.qml" - } - } - - Component.onCompleted: { - this.anchors.centerIn = undefined; - this.y = 150; - this.x = (parent.width - this.width) / 2; - Controller.setVPadHidden(true); - } - - Keys.onPressed: { - if (!visible) { - return - } - - if (event.modifiers === Qt.ControlModifier) - switch (event.key) { - case Qt.Key_A: - event.accepted = true - detailedText.selectAll() - break - case Qt.Key_C: - event.accepted = true - detailedText.copy() - break - case Qt.Key_Period: - if (Qt.platform.os === "osx") { - event.accepted = true - content.reject() - } - break - } else switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - event.accepted = true - destroy() - break - - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - break - } - } -} diff --git a/interface/resources/qml/hifi/+android/ActionBar.qml b/interface/resources/qml/hifi/+android/ActionBar.qml new file mode 100644 index 0000000000..d487901d6f --- /dev/null +++ b/interface/resources/qml/hifi/+android/ActionBar.qml @@ -0,0 +1,71 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Layouts 1.3 +import Qt.labs.settings 1.0 +import "../../styles-uit" +import "../../controls-uit" as HifiControlsUit +import "../../controls" as HifiControls +import ".." + +Item { + id: actionBar + x:0 + y:0 + width: 300 + height: 300 + z: -1 + + signal sendToScript(var message); + signal windowClosed(); + + property bool shown: true + + onShownChanged: { + actionBar.visible = shown; + } + + Rectangle { + anchors.fill : parent + color: "transparent" + Flow { + id: flowMain + spacing: 10 + flow: Flow.TopToBottom + layoutDirection: Flow.TopToBottom + anchors.fill: parent + anchors.margins: 4 + } + } + + Component.onCompleted: { + // put on bottom + x = 7; + y = 7; + width = 300; + height = 300; + } + + function addButton(properties) { + var component = Qt.createComponent("button.qml"); + if (component.status == Component.Ready) { + var button = component.createObject(flowMain); + // copy all properites to button + var keys = Object.keys(properties).forEach(function (key) { + button[key] = properties[key]; + }); + return button; + } else if( component.status == Component.Error) { + console.log("Load button errors " + component.errorString()); + } + } + + function urlHelper(src) { + if (src.match(/\bhttp/)) { + return src; + } else { + return "../../../" + src; + } + } + +} diff --git a/interface/resources/qml/hifi/+android/AudioBar.qml b/interface/resources/qml/hifi/+android/AudioBar.qml index f524595ef5..6cc17fccf7 100644 --- a/interface/resources/qml/hifi/+android/AudioBar.qml +++ b/interface/resources/qml/hifi/+android/AudioBar.qml @@ -38,13 +38,26 @@ Item { } } - Component.onCompleted: { - // put on bottom - x = 0; - y = 0; + function relocateAndResize(newWindowWidth, newWindowHeight) { + x = newWindowWidth-328; + y = 19; width = 300; height = 300; } + + function onWindowGeometryChanged(rect) { + relocateAndResize(rect.width, rect.height); + } + + Component.onCompleted: { + relocateAndResize(parent.width, parent.height); + Window.geometryChanged.connect(onWindowGeometryChanged); // In devices with bars appearing at startup we should listen for this + } + + Component.onDestruction: { + Window.geometryChanged.disconnect(onWindowGeometryChanged); + } + function addButton(properties) { var component = Qt.createComponent("button.qml"); diff --git a/interface/resources/qml/hifi/+android/avatarSelection.qml b/interface/resources/qml/hifi/+android/avatarSelection.qml deleted file mode 100644 index afa5634575..0000000000 --- a/interface/resources/qml/hifi/+android/avatarSelection.qml +++ /dev/null @@ -1,179 +0,0 @@ -// -// avatarSelection.qml -// interface/resources/qml/android -// -// Created by Gabriel Calero & Cristian Duarte on 21 Sep 2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Layouts 1.3 -import Hifi 1.0 - -import "../../styles" -import "." -import ".." -import ".." as QmlHifi -import "../../styles-uit" as HifiStyles - - -Item { - - id: top - - HifiConstants { id: android } - width: parent ? parent.width - android.dimen.windowLessWidth : 0 - height: parent ? parent.height - android.dimen.windowLessHeight : 0 - z: android.dimen.windowZ - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom } - - signal sendToScript(var message); - - property bool shown: true - - onShownChanged: { - top.visible = shown; - } - - - HifiConstants { id: hifi } - HifiStyles.HifiConstants { id: hifiStyleConstants } - - property int cardWidth: 250 *3; - property int cardHeight: 240 *3; - property int gap: 14 *3; - - property var avatarsArray: []; - property var extraOptionsArray: []; - - function hide() { - shown = false; - sendToScript ({ method: "hide" }); - } - - Rectangle { - - width: parent ? parent.width : 0 - height: parent ? parent.height : 0 - - MouseArea { - anchors.fill: parent - } - - gradient: Gradient { - GradientStop { position: 0.0; color: android.color.gradientTop } - GradientStop { position: 1.0; color: android.color.gradientBottom } - } - - QmlHifi.WindowHeader { - id: header - iconSource: "../../../../icons/avatar-i.svg" - titleText: "AVATAR" - } - - ListModel { id: avatars } - - ListView { - id: scroll - height: 250*3 - property int stackedCardShadowHeight: 10*3; - spacing: gap; - clip: true; - anchors { - left: parent.left - right: parent.right - top: header.bottom - topMargin: gap - leftMargin: gap - rightMargin: gap - } - model: avatars; - orientation: ListView.Horizontal; - delegate: QmlHifi.AvatarOption { - type: model.type; - thumbnailUrl: model.thumbnailUrl; - avatarUrl: model.avatarUrl; - avatarName: model.avatarName; - avatarSelected: model.avatarSelected; - methodName: model.methodName; - actionText: model.actionText; - } - highlightMoveDuration: -1; - highlightMoveVelocity: -1; - } - - } - - function escapeRegExp(str) { - return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); - } - function replaceAll(str, find, replace) { - return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); - } - - function refreshSelected(selectedAvatarUrl) { - // URL as ID? - avatarsArray.forEach(function (avatarData) { - avatarData.avatarSelected = (selectedAvatarUrl == avatarData.avatarUrl); - console.log('[avatarSelection] avatar : ', avatarData.avatarName, ' is selected? ' , avatarData.avatarSelected); - }); - } - - function addAvatar(name, thumbnailUrl, avatarUrl) { - avatarsArray.push({ - type: "avatar", - thumbnailUrl: thumbnailUrl, - avatarUrl: avatarUrl, - avatarName: name, - avatarSelected: false, - methodName: "", - actionText: "" - }); - } - - function showAvatars() { - avatars.clear(); - avatarsArray.forEach(function (avatarData) { - avatars.append(avatarData); - console.log('[avatarSelection] adding avatar to model: ', JSON.stringify(avatarData)); - }); - extraOptionsArray.forEach(function (extraData) { - avatars.append(extraData); - console.log('[avatarSelection] adding extra option to model: ', JSON.stringify(extraData)); - }); - } - - function addExtraOption(showName, thumbnailUrl, methodNameWhenClicked, actionText) { - extraOptionsArray.push({ - type: "extra", - thumbnailUrl: thumbnailUrl, - avatarUrl: "", - avatarName: showName, - avatarSelected: false, - methodName: methodNameWhenClicked, - actionText: actionText - }); - } - - function fromScript(message) { - //console.log("[CHAT] fromScript " + JSON.stringify(message)); - switch (message.type) { - case "addAvatar": - addAvatar(message.name, message.thumbnailUrl, message.avatarUrl); - break; - case "addExtraOption": - //(showName, thumbnailUrl, methodNameWhenClicked, actionText) - addExtraOption(message.showName, message.thumbnailUrl, message.methodNameWhenClicked, message.actionText); - break; - case "refreshSelected": - refreshSelected(message.selectedAvatarUrl); - break; - case "showAvatars": - showAvatars(); - break; - default: - } - } -} \ No newline at end of file diff --git a/interface/resources/qml/hifi/+android/bottomHudOptions.qml b/interface/resources/qml/hifi/+android/bottomHudOptions.qml index 860298149f..22beccf531 100644 --- a/interface/resources/qml/hifi/+android/bottomHudOptions.qml +++ b/interface/resources/qml/hifi/+android/bottomHudOptions.qml @@ -47,17 +47,14 @@ Item { spacing: 0 flow: Flow.LeftToRight layoutDirection: Flow.LeftToRight - anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter anchors.margins: 12 Rectangle { id: hideButton - height: android.dimen.headerHideWidth - width: android.dimen.headerHideHeight + height: android.dimen.headerHideHeight + width: android.dimen.headerHideWidth color: "#00000000" - anchors { - horizontalCenter: parent.horizontalCenter - } Image { id: hideIcon source: "../../../icons/show-up.svg" diff --git a/interface/resources/qml/hifi/+android/bottombar.qml b/interface/resources/qml/hifi/+android/bottombar.qml deleted file mode 100644 index 66117d0389..0000000000 --- a/interface/resources/qml/hifi/+android/bottombar.qml +++ /dev/null @@ -1,151 +0,0 @@ -// -// bottomHudOptions.qml -// interface/resources/qml/android -// -// Created by Gabriel Calero & Cristian Duarte on 19 Jan 2018 -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.3 -import Qt.labs.settings 1.0 -import "../../styles" as Styles -import "../../styles-uit" -import "../../controls-uit" as HifiControlsUit -import "../../controls" as HifiControls -import ".." -import "." - -Item { - id: bar - x:0 - height: 255 - - property bool shown: true - - signal sendToScript(var message); - - onShownChanged: { - bar.visible = shown; - } - - function hide() { - //shown = false; - sendToScript({ method: "hide" }); - } - - Styles.HifiConstants { id: hifi } - HifiConstants { id: android } - MouseArea { - anchors.fill: parent - } - - Rectangle { - id: background - anchors.fill : parent - color: "#FF000000" - border.color: "#FFFFFF" - anchors.bottomMargin: -1 - anchors.leftMargin: -1 - anchors.rightMargin: -1 - Flow { - id: flowMain - spacing: 10 - anchors.fill: parent - anchors.topMargin: 12 - anchors.bottomMargin: 12 - anchors.rightMargin: 12 - anchors.leftMargin: 72 - } - - - Rectangle { - id: hideButton - height: android.dimen.headerHideWidth - width: android.dimen.headerHideHeight - color: "#00000000" - anchors { - right: parent.right - rightMargin: android.dimen.headerHideRightMargin - top: parent.top - topMargin: android.dimen.headerHideTopMargin - } - - Image { - id: hideIcon - source: "../../../icons/hide.svg" - width: android.dimen.headerHideIconWidth - height: android.dimen.headerHideIconHeight - anchors { - horizontalCenter: parent.horizontalCenter - top: parent.top - } - } - FiraSansRegular { - anchors { - top: hideIcon.bottom - horizontalCenter: hideIcon.horizontalCenter - topMargin: 12 - } - text: "HIDE" - color: "#FFFFFF" - font.pixelSize: hifi.fonts.pixelSize * 2.5; - } - - MouseArea { - anchors.fill: parent - onClicked: { - hide(); - } - } - } - } - - function relocateAndResize(newWindowWidth, newWindowHeight) { - width = newWindowWidth; - y = newWindowHeight - height; - } - - function onWindowGeometryChanged(rect) { - relocateAndResize(rect.width, rect.height); - } - - Component.onCompleted: { - // put on bottom - relocateAndResize(Window.innerWidth, Window.innerHeight); - Window.geometryChanged.connect(onWindowGeometryChanged); // In devices with bars appearing at startup we should listen for this - } - - Component.onDestruction: { - Window.geometryChanged.disconnect(onWindowGeometryChanged); - } - - function addButton(properties) { - var component = Qt.createComponent("button.qml"); - if (component.status == Component.Ready) { - var button = component.createObject(flowMain); - // copy all properites to button - var keys = Object.keys(properties).forEach(function (key) { - button[key] = properties[key]; - }); - return button; - } else if( component.status == Component.Error) { - console.log("Load button errors " + component.errorString()); - } - } - - function urlHelper(src) { - if (src.match(/\bhttp/)) { - return src; - } else { - return "../../../" + src; - } - } - -} diff --git a/interface/resources/qml/hifi/+android/button.qml b/interface/resources/qml/hifi/+android/button.qml index 3e9ce39351..a4c65b3c6f 100644 --- a/interface/resources/qml/hifi/+android/button.qml +++ b/interface/resources/qml/hifi/+android/button.qml @@ -32,6 +32,9 @@ Item { property string hoverTextColor: "#ffffff" property string activeTextColor: "#ffffff" property string activeHoverTextColor: "#ffffff" + property string fontFamily: "FiraSans" + property bool fontBold: false + property int bottomMargin: 30 property bool isEntered: false @@ -92,8 +95,8 @@ Item { id: text color: "#ffffff" text: button.text - font.family: "FiraSans" - //font.bold: true + font.family: button.fontFamily + font.bold: button.fontBold font.pixelSize: textSize anchors.bottom: parent.bottom anchors.bottomMargin: bottomMargin @@ -143,15 +146,12 @@ Item { PropertyChanges { target: buttonBg - //color: "#cfcfcf" - //opacity: 1 color: button.hoverBgColor opacity: button.hoverBgOpacity } PropertyChanges { target: text - //color: "#ffffff" color: button.hoverTextColor text: button.hoverText } @@ -166,15 +166,12 @@ Item { PropertyChanges { target: buttonBg - //color: "#1fc6a6" - //opacity: 1 color: button.activeBgColor opacity: button.activeBgOpacity } PropertyChanges { target: text - //color: "#333333" color: button.activeTextColor text: button.activeText } @@ -189,15 +186,12 @@ Item { PropertyChanges { target: buttonBg - //color: "#ff0000" - //opacity: 1 color: button.activeHoverBgColor opacity: button.activeHoverBgOpacity } PropertyChanges { target: text - //color: "#333333" color: button.activeHoverTextColor text: button.activeHoverText } @@ -212,15 +206,12 @@ Item { PropertyChanges { target: buttonBg - //color: "#9A9A9A" - //opacity: 0.1 color: button.bgColor opacity: button.bgOpacity } PropertyChanges { target: text - //color: "#ffffff" color: button.textColor text: button.text } diff --git a/interface/resources/qml/hifi/+android/modesbar.qml b/interface/resources/qml/hifi/+android/modesbar.qml index fe71314ece..994bf1efe4 100644 --- a/interface/resources/qml/hifi/+android/modesbar.qml +++ b/interface/resources/qml/hifi/+android/modesbar.qml @@ -10,24 +10,25 @@ import ".." Item { id: modesbar - y:60 - Rectangle { - anchors.fill : parent - color: "transparent" - Flow { - id: flowMain - spacing: 0 - flow: Flow.TopToBottom - layoutDirection: Flow.TopToBottom - anchors.fill: parent - anchors.margins: 4 - } - } + y:5 + + function relocateAndResize(newWindowWidth, newWindowHeight) { + width = 300; + height = 300; + x = newWindowWidth - 565; + } + + function onWindowGeometryChanged(rect) { + relocateAndResize(rect.width, rect.height); + } Component.onCompleted: { - width = 300 + 30; // That 30 is extra regardless the qty of items shown - height = 300 + 30; - x=Window.innerWidth - width; + relocateAndResize(parent.width, parent.height); + Window.geometryChanged.connect(onWindowGeometryChanged); // In devices with bars appearing at startup we should listen for this + } + + Component.onDestruction: { + Window.geometryChanged.disconnect(onWindowGeometryChanged); } function addButton(properties) { @@ -35,7 +36,7 @@ Item { console.log("load button"); if (component.status == Component.Ready) { console.log("load button 2"); - var button = component.createObject(flowMain); + var button = component.createObject(modesbar); // copy all properites to button var keys = Object.keys(properties).forEach(function (key) { button[key] = properties[key]; @@ -59,14 +60,12 @@ Item { function fromScript(message) { switch (message.type) { - case "allButtonsShown": - modesbar.height = flowMain.children.length * 300 + 30; // That 30 is extra regardless the qty of items shown - break; - case "inactiveButtonsHidden": - modesbar.height = 300 + 30; - break; + case "switch": + // message.params.to + // still not needed + break; default: - break; + break; } } diff --git a/interface/src/AndroidHelper.cpp b/interface/src/AndroidHelper.cpp new file mode 100644 index 0000000000..b04a6ff2c4 --- /dev/null +++ b/interface/src/AndroidHelper.cpp @@ -0,0 +1,20 @@ +// +// AndroidHelper.cpp +// interface/src +// +// Created by Gabriel Calero & Cristian Duarte on 3/30/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "AndroidHelper.h" +#include + +void AndroidHelper::requestActivity(const QString &activityName) { + emit androidActivityRequested(activityName); +} + +void AndroidHelper::goBackFromAndroidActivity() { + emit backFromAndroidActivity(); +} \ No newline at end of file diff --git a/interface/src/AndroidHelper.h b/interface/src/AndroidHelper.h new file mode 100644 index 0000000000..34f32b461b --- /dev/null +++ b/interface/src/AndroidHelper.h @@ -0,0 +1,37 @@ +// +// AndroidHelper.h +// interface/src +// +// Created by Gabriel Calero & Cristian Duarte on 3/30/18. +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_Android_Helper_h +#define hifi_Android_Helper_h + +#include + +class AndroidHelper : public QObject { + Q_OBJECT +public: + static AndroidHelper& instance() { + static AndroidHelper instance; + return instance; + } + void requestActivity(const QString &activityName); + void goBackFromAndroidActivity(); + + AndroidHelper(AndroidHelper const&) = delete; + void operator=(AndroidHelper const&) = delete; +signals: + void androidActivityRequested(const QString &activityName); + void backFromAndroidActivity(); + +private: + AndroidHelper() {} +}; + +#endif \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cd4562da54..75e6472078 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -252,6 +252,7 @@ extern "C" { #if defined(Q_OS_ANDROID) #include +#include "AndroidHelper.h" #endif enum ApplicationEvent { @@ -1258,6 +1259,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] { getEntities()->reloadEntityScripts(); + loadAvatarScripts(getMyAvatar()->getScriptUrls()); }, Qt::QueuedConnection); connect(scriptEngines, &ScriptEngines::scriptLoadError, @@ -2731,6 +2733,9 @@ void Application::initializeUi() { offscreenUi->resume(); connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){ resizeGL(); + if (_touchscreenVirtualPadDevice) { + _touchscreenVirtualPadDevice->resize(); + } }); // This will set up the input plugins UI @@ -3166,11 +3171,14 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { // If this is a first run we short-circuit the address passed in if (firstRun.get()) { -#if !defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) + qCDebug(interfaceapp) << "First run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("default location") : addressLookupString); + DependencyManager::get()->loadSettings(addressLookupString); +#else showHelp(); -#endif DependencyManager::get()->goToEntry(); sentTo = SENT_TO_ENTRY; +#endif firstRun.set(false); } else { @@ -3740,6 +3748,12 @@ void Application::keyPressEvent(QKeyEvent* event) { void Application::keyReleaseEvent(QKeyEvent* event) { _keysPressed.remove(event->key()); +#if defined(Q_OS_ANDROID) + if (event->key() == Qt::Key_Back) { + event->accept(); + openAndroidActivity("Home"); + } +#endif _controllerScriptingInterface->emitKeyReleaseEvent(event); // send events to any registered scripts // if one of our scripts have asked to capture this event, then stop processing it @@ -4807,6 +4821,31 @@ void Application::init() { }, Qt::QueuedConnection); } +void Application::loadAvatarScripts(const QVector& urls) { + auto scriptEngines = DependencyManager::get(); + auto runningScripts = scriptEngines->getRunningScripts(); + for (auto url : urls) { + int index = runningScripts.indexOf(url); + if (index < 0) { + auto scriptEnginePointer = scriptEngines->loadScript(url, false); + if (scriptEnginePointer) { + scriptEnginePointer->setType(ScriptEngine::Type::AVATAR); + } + } + } +} + +void Application::unloadAvatarScripts() { + auto scriptEngines = DependencyManager::get(); + auto urls = scriptEngines->getRunningScripts(); + for (auto url : urls) { + auto scriptEngine = scriptEngines->getScriptEngine(url); + if (scriptEngine->getType() == ScriptEngine::Type::AVATAR) { + scriptEngines->stopScript(url, false); + } + } +} + void Application::updateLOD(float deltaTime) const { PerformanceTimer perfTimer("LOD"); // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode @@ -7828,6 +7867,26 @@ void Application::switchDisplayMode() { _previousHMDWornStatus = currentHMDWornStatus; } +void Application::setShowBulletWireframe(bool value) { + _physicsEngine->setShowBulletWireframe(value); +} + +void Application::setShowBulletAABBs(bool value) { + _physicsEngine->setShowBulletAABBs(value); +} + +void Application::setShowBulletContactPoints(bool value) { + _physicsEngine->setShowBulletContactPoints(value); +} + +void Application::setShowBulletConstraints(bool value) { + _physicsEngine->setShowBulletConstraints(value); +} + +void Application::setShowBulletConstraintLimits(bool value) { + _physicsEngine->setShowBulletConstraintLimits(value); +} + void Application::startHMDStandBySession() { _autoSwitchDisplayModeSupportedHMDPlugin->startStandBySession(); } @@ -8009,4 +8068,29 @@ void Application::saveNextPhysicsStats(QString filename) { _physicsEngine->saveNextPhysicsStats(filename); } +void Application::openAndroidActivity(const QString& activityName) { +#if defined(Q_OS_ANDROID) + AndroidHelper::instance().requestActivity(activityName); +#endif +} + +#if defined(Q_OS_ANDROID) +void Application::enterBackground() { + QMetaObject::invokeMethod(DependencyManager::get().data(), + "stop", Qt::BlockingQueuedConnection); + //GC: commenting it out until we fix it + //getActiveDisplayPlugin()->deactivate(); +} +void Application::enterForeground() { + QMetaObject::invokeMethod(DependencyManager::get().data(), + "start", Qt::BlockingQueuedConnection); + //GC: commenting it out until we fix it + /*if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) { + qWarning() << "Could not re-activate display plugin"; + }*/ + +} +#endif + +#include "Application_jni.cpp" #include "Application.moc" diff --git a/interface/src/Application.h b/interface/src/Application.h index 6d611bc8e2..e1787b7a32 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -243,6 +243,7 @@ public: bool isAboutToQuit() const { return _aboutToQuit; } bool isPhysicsEnabled() const { return _physicsEnabled; } + PhysicsEnginePointer getPhysicsEngine() { return _physicsEngine; } // the isHMDMode is true whenever we use the interface from an HMD and not a standard flat display // rendering of several elements depend on that @@ -290,6 +291,14 @@ public: void replaceDomainContent(const QString& url); + void loadAvatarScripts(const QVector& urls); + void unloadAvatarScripts(); + +#if defined(Q_OS_ANDROID) + void enterBackground(); + void enterForeground(); +#endif + signals: void svoImportRequested(const QString& url); @@ -400,6 +409,8 @@ public slots: Q_INVOKABLE bool askBeforeSetAvatarUrl(const QString& avatarUrl) { return askToSetAvatarUrl(avatarUrl); } void updateVerboseLogging(); + Q_INVOKABLE void openAndroidActivity(const QString& activityName); + private slots: void onDesktopRootItemCreated(QQuickItem* qmlContext); @@ -453,6 +464,12 @@ private slots: void handleSandboxStatus(QNetworkReply* reply); void switchDisplayMode(); + void setShowBulletWireframe(bool value); + void setShowBulletAABBs(bool value); + void setShowBulletContactPoints(bool value); + void setShowBulletConstraints(bool value); + void setShowBulletConstraintLimits(bool value); + private: void init(); bool handleKeyEventForFocusedEntityOrOverlay(QEvent* event); diff --git a/interface/src/Application_jni.cpp b/interface/src/Application_jni.cpp new file mode 100644 index 0000000000..5e9f1ac29e --- /dev/null +++ b/interface/src/Application_jni.cpp @@ -0,0 +1,24 @@ +#if defined(Q_OS_ANDROID) + +#include +#include "AndroidHelper.h" + +extern "C" { + +JNIEXPORT void +Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterBackground(JNIEnv *env, jobject obj) { + if (qApp) { + qApp->enterBackground(); + } +} + +JNIEXPORT void +Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterForeground(JNIEnv *env, jobject obj) { + if (qApp) { + qApp->enterForeground(); + } +} + + +} +#endif \ No newline at end of file diff --git a/interface/src/AvatarBookmarks.h b/interface/src/AvatarBookmarks.h index 177e6e493e..7b47ea8af7 100644 --- a/interface/src/AvatarBookmarks.h +++ b/interface/src/AvatarBookmarks.h @@ -18,6 +18,10 @@ /**jsdoc * This API helps manage adding and deleting avatar bookmarks. * @namespace AvatarBookmarks + * + * @hifi-interface + * @hifi-client-entity + * */ class AvatarBookmarks: public Bookmarks, public Dependency { diff --git a/interface/src/LODManager.h b/interface/src/LODManager.h index 96d92e91e9..8f88da63a8 100644 --- a/interface/src/LODManager.h +++ b/interface/src/LODManager.h @@ -37,6 +37,10 @@ class AABox; /**jsdoc * The LOD class manages your Level of Detail functions within Interface. * @namespace LODManager + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} presentTime Read-only. * @property {number} engineRunTime Read-only. * @property {number} gpuTime Read-only. diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 50ff65ad1a..60d5abf260 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -735,6 +735,12 @@ Menu::Menu() { } addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls, 0, false, qApp->getEntities().data(), SIGNAL(setRenderDebugHulls())); + addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletWireframe, 0, false, qApp, SLOT(setShowBulletWireframe(bool))); + addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletAABBs, 0, false, qApp, SLOT(setShowBulletAABBs(bool))); + addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletContactPoints, 0, false, qApp, SLOT(setShowBulletContactPoints(bool))); + addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletConstraints, 0, false, qApp, SLOT(setShowBulletConstraints(bool))); + addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletConstraintLimits, 0, false, qApp, SLOT(setShowBulletConstraintLimits(bool))); + // Developer > Ask to Reset Settings addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::AskToResetSettings, 0, false); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index c8c8ee42df..20375a71b2 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -143,6 +143,11 @@ namespace MenuOption { const QString PhysicsShowHulls = "Draw Collision Shapes"; const QString PhysicsShowOwned = "Highlight Simulation Ownership"; const QString VerboseLogging = "Verbose Logging"; + const QString PhysicsShowBulletWireframe = "Show Bullet Collision"; + const QString PhysicsShowBulletAABBs = "Show Bullet Bounding Boxes"; + const QString PhysicsShowBulletContactPoints = "Show Bullet Contact Points"; + const QString PhysicsShowBulletConstraints = "Show Bullet Constraints"; + const QString PhysicsShowBulletConstraintLimits = "Show Bullet Constraint Limits"; const QString PipelineWarnings = "Log Render Pipeline Warnings"; const QString Preferences = "General..."; const QString Quit = "Quit"; diff --git a/interface/src/ModelPackager.cpp b/interface/src/ModelPackager.cpp index 5f4c7526e0..0e34eebc80 100644 --- a/interface/src/ModelPackager.cpp +++ b/interface/src/ModelPackager.cpp @@ -156,9 +156,11 @@ bool ModelPackager::zipModel() { QByteArray nameField = _mapping.value(NAME_FIELD).toByteArray(); tempDir.mkpath(nameField + "/textures"); + tempDir.mkpath(nameField + "/scripts"); QDir fbxDir(tempDir.path() + "/" + nameField); QDir texDir(fbxDir.path() + "/textures"); - + QDir scriptDir(fbxDir.path() + "/scripts"); + // Copy textures listTextures(); if (!_textures.empty()) { @@ -166,6 +168,23 @@ bool ModelPackager::zipModel() { _texDir = _modelFile.path() + "/" + texdirField; copyTextures(_texDir, texDir); } + + // Copy scripts + QByteArray scriptField = _mapping.value(SCRIPT_FIELD).toByteArray(); + _mapping.remove(SCRIPT_FIELD); + if (scriptField.size() > 1) { + tempDir.mkpath(nameField + "/scripts"); + _scriptDir = _modelFile.path() + "/" + scriptField; + QDir wdir = QDir(_scriptDir); + _mapping.remove(SCRIPT_FIELD); + wdir.setSorting(QDir::Name | QDir::Reversed); + auto list = wdir.entryList(QDir::NoDotAndDotDot | QDir::AllEntries); + for (auto script : list) { + auto sc = tempDir.relativeFilePath(scriptDir.path()) + "/" + QUrl(script).fileName(); + _mapping.insertMulti(SCRIPT_FIELD, sc); + } + copyDirectoryContent(wdir, scriptDir); + } // Copy LODs QVariantHash lodField = _mapping.value(LOD_FIELD).toHash(); @@ -189,7 +208,10 @@ bool ModelPackager::zipModel() { // Correct FST _mapping[FILENAME_FIELD] = tempDir.relativeFilePath(newPath); _mapping[TEXDIR_FIELD] = tempDir.relativeFilePath(texDir.path()); - + + for (auto multi : _mapping.values(SCRIPT_FIELD)) { + multi.fromValue(tempDir.relativeFilePath(scriptDir.path()) + multi.toString()); + } // Copy FST QFile fst(tempDir.path() + "/" + nameField + ".fst"); if (fst.open(QIODevice::WriteOnly)) { @@ -237,7 +259,9 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename if (!mapping.contains(TEXDIR_FIELD)) { mapping.insert(TEXDIR_FIELD, "."); } - + if (!mapping.contains(SCRIPT_FIELD)) { + mapping.insert(SCRIPT_FIELD, "."); + } // mixamo/autodesk defaults if (!mapping.contains(SCALE_FIELD)) { mapping.insert(SCALE_FIELD, 1.0); diff --git a/interface/src/ModelPackager.h b/interface/src/ModelPackager.h index 10942833f9..60b3825c4d 100644 --- a/interface/src/ModelPackager.h +++ b/interface/src/ModelPackager.h @@ -37,10 +37,12 @@ private: QFileInfo _fbxInfo; FSTReader::ModelType _modelType; QString _texDir; + QString _scriptDir; QVariantHash _mapping; std::unique_ptr _geometry; QStringList _textures; + QStringList _scripts; }; diff --git a/interface/src/ModelPropertiesDialog.cpp b/interface/src/ModelPropertiesDialog.cpp index ae352974ae..35b07aa2b2 100644 --- a/interface/src/ModelPropertiesDialog.cpp +++ b/interface/src/ModelPropertiesDialog.cpp @@ -43,6 +43,9 @@ _geometry(geometry) form->addRow("Texture Directory:", _textureDirectory = new QPushButton()); connect(_textureDirectory, SIGNAL(clicked(bool)), SLOT(chooseTextureDirectory())); + form->addRow("Script Directory:", _scriptDirectory = new QPushButton()); + connect(_scriptDirectory, SIGNAL(clicked(bool)), SLOT(chooseScriptDirectory())); + form->addRow("Scale:", _scale = new QDoubleSpinBox()); _scale->setMaximum(FLT_MAX); _scale->setSingleStep(0.01); @@ -100,6 +103,7 @@ QVariantHash ModelPropertiesDialog::getMapping() const { mapping.insert(TYPE_FIELD, getType()); mapping.insert(NAME_FIELD, _name->text()); mapping.insert(TEXDIR_FIELD, _textureDirectory->text()); + mapping.insert(SCRIPT_FIELD, _scriptDirectory->text()); mapping.insert(SCALE_FIELD, QString::number(_scale->value())); // update the joint indices @@ -157,6 +161,7 @@ void ModelPropertiesDialog::reset() { _name->setText(_originalMapping.value(NAME_FIELD).toString()); _textureDirectory->setText(_originalMapping.value(TEXDIR_FIELD).toString()); _scale->setValue(_originalMapping.value(SCALE_FIELD).toDouble()); + _scriptDirectory->setText(_originalMapping.value(SCRIPT_FIELD).toString()); QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); @@ -207,6 +212,20 @@ void ModelPropertiesDialog::chooseTextureDirectory() { _textureDirectory->setText(directory.length() == _basePath.length() ? "." : directory.mid(_basePath.length() + 1)); } +void ModelPropertiesDialog::chooseScriptDirectory() { + QString directory = QFileDialog::getExistingDirectory(this, "Choose Script Directory", + _basePath + "/" + _scriptDirectory->text()); + if (directory.isEmpty()) { + return; + } + if (!directory.startsWith(_basePath)) { + OffscreenUi::asyncWarning(NULL, "Invalid script directory", "Script directory must be child of base path."); + return; + } + _scriptDirectory->setText(directory.length() == _basePath.length() ? "." : directory.mid(_basePath.length() + 1)); +} + + void ModelPropertiesDialog::updatePivotJoint() { _pivotJoint->setEnabled(!_pivotAboutCenter->isChecked()); } diff --git a/interface/src/ModelPropertiesDialog.h b/interface/src/ModelPropertiesDialog.h index 11abc5ab54..e3c2d8ed6a 100644 --- a/interface/src/ModelPropertiesDialog.h +++ b/interface/src/ModelPropertiesDialog.h @@ -37,6 +37,7 @@ public: private slots: void reset(); void chooseTextureDirectory(); + void chooseScriptDirectory(); void updatePivotJoint(); void createNewFreeJoint(const QString& joint = QString()); @@ -52,6 +53,7 @@ private: FBXGeometry _geometry; QLineEdit* _name = nullptr; QPushButton* _textureDirectory = nullptr; + QPushButton* _scriptDirectory = nullptr; QDoubleSpinBox* _scale = nullptr; QDoubleSpinBox* _translationX = nullptr; QDoubleSpinBox* _translationY = nullptr; diff --git a/interface/src/SpeechRecognizer.h b/interface/src/SpeechRecognizer.h index d5f9031cfc..b22ab73837 100644 --- a/interface/src/SpeechRecognizer.h +++ b/interface/src/SpeechRecognizer.h @@ -24,6 +24,9 @@ /**jsdoc * @namespace SpeechRecognizer + * + * @hifi-interface + * @hifi-client-entity */ class SpeechRecognizer : public QObject, public Dependency { Q_OBJECT diff --git a/interface/src/audio/AudioScope.h b/interface/src/audio/AudioScope.h index ff8bfda6dd..41cee8d17d 100644 --- a/interface/src/audio/AudioScope.h +++ b/interface/src/audio/AudioScope.h @@ -28,6 +28,10 @@ class AudioScope : public QObject, public Dependency { /**jsdoc * The AudioScope API helps control the Audio Scope features in Interface * @namespace AudioScope + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} scopeInput Read-only. * @property {number} scopeOutputLeft Read-only. * @property {number} scopeOutputRight Read-only. diff --git a/interface/src/avatar/AvatarManager.h b/interface/src/avatar/AvatarManager.h index d2655914d2..7f5aa00466 100644 --- a/interface/src/avatar/AvatarManager.h +++ b/interface/src/avatar/AvatarManager.h @@ -30,6 +30,9 @@ /**jsdoc * The AvatarManager API has properties and methods which manage Avatars within the same domain. * @namespace AvatarManager + * + * @hifi-interface + * @hifi-client-entity */ class AvatarManager : public AvatarHashMap { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 249a765d92..e116b3830e 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -121,6 +121,19 @@ MyAvatar::MyAvatar(QThread* thread) : _skeletonModel = std::make_shared(this, nullptr); connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); + connect(_skeletonModel.get(), &Model::setURLFinished, this, [this](bool success) { + if (success) { + qApp->unloadAvatarScripts(); + _shouldLoadScripts = true; + } + }); + connect(_skeletonModel.get(), &Model::rigReady, this, [this]() { + if (_shouldLoadScripts) { + auto geometry = getSkeletonModel()->getFBXGeometry(); + qApp->loadAvatarScripts(geometry.scripts); + _shouldLoadScripts = false; + } + }); connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); @@ -2037,12 +2050,14 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) { _attachmentData[i].jointName.compare("RightEye", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) { + uint8_t modelRenderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE; + modelRenderTagBits |= render::ItemKey::TAG_BITS_1; + _attachmentModels[i]->setVisibleInScene(true, qApp->getMain3DScene(), + modelRenderTagBits, false); - _attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(), - render::ItemKey::TAG_BITS_NONE, true); - - _attachmentModels[i]->setCanCastShadow(shouldDrawHead, qApp->getMain3DScene(), - render::ItemKey::TAG_BITS_NONE, true); + uint8_t castShadowRenderTagBits = render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1; + _attachmentModels[i]->setCanCastShadow(true, qApp->getMain3DScene(), + castShadowRenderTagBits, false); } } } @@ -2839,6 +2854,11 @@ void MyAvatar::setWalkSpeed(float value) { _walkSpeed.set(value); } +QVector MyAvatar::getScriptUrls() { + QVector scripts = _skeletonModel->isLoaded() ? _skeletonModel->getFBXGeometry().scripts : QVector(); + return scripts; +} + glm::vec3 MyAvatar::getPositionForAudio() { glm::vec3 result; switch (_audioListenerMode) { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 74f7a3c89f..ac3d3cd2f4 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -985,6 +985,8 @@ public: void setWalkSpeed(float value); float getWalkSpeed() const; + QVector getScriptUrls(); + public slots: /**jsdoc @@ -1322,7 +1324,6 @@ signals: private slots: void leaveDomain(); - protected: virtual void beParentOfChild(SpatiallyNestablePointer newChild) const override; virtual void forgetChild(SpatiallyNestablePointer newChild) const override; @@ -1564,6 +1565,9 @@ private: // max unscaled forward movement speed ThreadSafeValueCache _walkSpeed { DEFAULT_AVATAR_MAX_WALKING_SPEED }; float _walkSpeedScalar { AVATAR_WALK_SPEED_SCALAR }; + + // load avatar scripts once when rig is ready + bool _shouldLoadScripts { false }; }; QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode); diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index d4af0bbd37..4fe36b582e 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -29,6 +29,9 @@ /**jsdoc * The FaceTracker API helps manage facial tracking hardware. * @namespace FaceTracker + * + * @hifi-interface + * @hifi-client-entity */ class DdeFaceTracker : public FaceTracker, public Dependency { diff --git a/interface/src/java/io/highfidelity/interface/InterfaceActivity.java b/interface/src/java/io/highfidelity/interface/InterfaceActivity.java index c7cbdd3dff..ae10c320f8 100644 --- a/interface/src/java/io/highfidelity/interface/InterfaceActivity.java +++ b/interface/src/java/io/highfidelity/interface/InterfaceActivity.java @@ -15,7 +15,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.WindowManager; -import android.util.Log; import org.qtproject.qt5.android.bindings.QtActivity; public class InterfaceActivity extends QtActivity { diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h index f2cd9287a5..2568dd8457 100644 --- a/interface/src/raypick/PickScriptingInterface.h +++ b/interface/src/raypick/PickScriptingInterface.h @@ -18,6 +18,10 @@ * The Picks API lets you create and manage objects for repeatedly calculating intersections in different ways. * * @namespace Picks + * + * @hifi-interface + * @hifi-client-entity + * * @property PICK_NOTHING {number} A filter flag. Don't intersect with anything. * @property PICK_ENTITIES {number} A filter flag. Include entities when intersecting. * @property PICK_OVERLAYS {number} A filter flag. Include overlays when intersecting. diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h index 1cc7b56503..e7acfd4037 100644 --- a/interface/src/raypick/PointerScriptingInterface.h +++ b/interface/src/raypick/PointerScriptingInterface.h @@ -19,6 +19,9 @@ * Pointers can also be configured to automatically generate PointerEvents. * * @namespace Pointers + * + * @hifi-interface + * @hifi-client-entity */ class PointerScriptingInterface : public QObject, public Dependency { diff --git a/interface/src/scripting/AccountServicesScriptingInterface.h b/interface/src/scripting/AccountServicesScriptingInterface.h index d38a84d8fa..5774ee1da5 100644 --- a/interface/src/scripting/AccountServicesScriptingInterface.h +++ b/interface/src/scripting/AccountServicesScriptingInterface.h @@ -38,6 +38,9 @@ class AccountServicesScriptingInterface : public QObject { /**jsdoc * The AccountServices API contains helper functions related to user connectivity * + * @hifi-interface + * @hifi-client-entity + * * @namespace AccountServices * @property {string} username Read-only. * @property {boolean} loggedIn Read-only. diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index c77d1522b5..f0a4328c2f 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -27,8 +27,14 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable { /**jsdoc * The Audio API features tools to help control audio contexts and settings. - * + * * @namespace Audio + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {boolean} muted * @property {boolean} noiseReduction * @property {number} inputVolume diff --git a/interface/src/scripting/ClipboardScriptingInterface.h b/interface/src/scripting/ClipboardScriptingInterface.h index cce300e831..32b8c64a7d 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.h +++ b/interface/src/scripting/ClipboardScriptingInterface.h @@ -21,6 +21,9 @@ * The Clipboard API enables you to export and import entities to and from JSON files. * * @namespace Clipboard + * + * @hifi-interface + * @hifi-client-entity */ class ClipboardScriptingInterface : public QObject { Q_OBJECT diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h index 4fceda3b04..e16383e234 100644 --- a/interface/src/scripting/ControllerScriptingInterface.h +++ b/interface/src/scripting/ControllerScriptingInterface.h @@ -200,7 +200,10 @@ class ScriptEngine; * * @namespace Controller * - * @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end + * @hifi-interface + * @hifi-client-entity + * + * @property {Controller.Actions} Actions - Predefined actions on Interface and the user's avatar. These can be used as end * points in a {@link RouteObject} mapping. A synonym for Controller.Hardware.Actions. * Read-only.
* Default mappings are provided from the Controller.Hardware.Keyboard and Controller.Standard to diff --git a/interface/src/scripting/GooglePolyScriptingInterface.h b/interface/src/scripting/GooglePolyScriptingInterface.h index 5c37b394fa..fb5aed9759 100644 --- a/interface/src/scripting/GooglePolyScriptingInterface.h +++ b/interface/src/scripting/GooglePolyScriptingInterface.h @@ -18,6 +18,9 @@ /**jsdoc * The GooglePoly API allows you to interact with Google Poly models direct from inside High Fidelity. * @namespace GooglePoly + * + * @hifi-interface + * @hifi-client-entity */ class GooglePolyScriptingInterface : public QObject, public Dependency { diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 9b2482e73a..d2a272851f 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -28,7 +28,11 @@ class QScriptEngine; * The HMD API provides access to the HMD used in VR display mode. * * @namespace HMD - * @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise + * + * @hifi-interface + * @hifi-client-entity + * + * @property {Vec3} position - The position of the HMD if currently in VR display mode, otherwise * {@link Vec3(0)|Vec3.ZERO}. Read-only. * @property {Quat} orientation - The orientation of the HMD if currently in VR display mode, otherwise * {@link Quat(0)|Quat.IDENTITY}. Read-only. diff --git a/interface/src/scripting/MenuScriptingInterface.h b/interface/src/scripting/MenuScriptingInterface.h index 649c444eaf..81cf775de8 100644 --- a/interface/src/scripting/MenuScriptingInterface.h +++ b/interface/src/scripting/MenuScriptingInterface.h @@ -32,6 +32,9 @@ class MenuItemProperties; * If a menu item doesn't belong to a group it is always displayed. * * @namespace Menu + * + * @hifi-interface + * @hifi-client-entity */ /** diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 86ececcbca..8b5c12e3dc 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -86,6 +86,9 @@ protected: * The Selection API provides a means of grouping together avatars, entities, and overlays in named lists. * @namespace Selection * + * @hifi-interface + * @hifi-client-entity + * * @example Outline an entity when it is grabbed by a controller. * // Create a box and copy the following text into the entity's "Script URL" field. * (function () { diff --git a/interface/src/scripting/SettingsScriptingInterface.h b/interface/src/scripting/SettingsScriptingInterface.h index 9e0271601b..32d868bb24 100644 --- a/interface/src/scripting/SettingsScriptingInterface.h +++ b/interface/src/scripting/SettingsScriptingInterface.h @@ -18,6 +18,9 @@ /**jsdoc * The Settings API provides a facility to store and retrieve values that persist between Interface runs. * @namespace Settings + * + * @hifi-interface + * @hifi-client-entity */ class SettingsScriptingInterface : public QObject { diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 0b766d2097..348882e0f8 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -28,7 +28,11 @@ * physics. * * @namespace Window - * @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other + * + * @hifi-interface + * @hifi-client-entity + * + * @property {number} innerWidth - The width of the drawable area of the Interface window (i.e., without borders or other * chrome), in pixels. Read-only. * @property {number} innerHeight - The height of the drawable area of the Interface window (i.e., without borders or other * chrome), in pixels. Read-only. diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index 87bf09a252..789a2a2bdf 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -58,9 +58,8 @@ void AddressBarDialog::loadHome() { qDebug() << "Called LoadHome"; auto locationBookmarks = DependencyManager::get(); QString homeLocation = locationBookmarks->addressForBookmark(LocationBookmarks::HOME_BOOKMARK); - const QString DEFAULT_HOME_LOCATION = "localhost"; if (homeLocation == "") { - homeLocation = DEFAULT_HOME_LOCATION; + homeLocation = DEFAULT_HIFI_ADDRESS; } DependencyManager::get()->handleLookupString(homeLocation); } diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index a9d1509770..e67d35e59f 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -26,6 +26,10 @@ class AvatarInputs : public QObject { /**jsdoc * API to help manage your Avatar's input * @namespace AvatarInputs + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} cameraEnabled Read-only. * @property {boolean} cameraMuted Read-only. * @property {boolean} isHMD Read-only. diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index b80a3a70fb..808c3a4ee3 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -31,9 +31,6 @@ #include "EntityTree.h" #include "ContextOverlayLogging.h" -/**jsdoc -* @namespace ContextOverlay -*/ class ContextOverlayInterface : public QObject, public Dependency { Q_OBJECT diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index c2f6e3e693..cf1151b46a 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -76,6 +76,10 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R * The Overlays API provides facilities to create and interact with overlays. Overlays are 2D and 3D objects visible only to * yourself and that aren't persisted to the domain. They are used for UI. * @namespace Overlays + * + * @hifi-interface + * @hifi-client-entity + * * @property {Uuid} keyboardFocusOverlay - Get or set the {@link Overlays.OverlayType|web3d} overlay that has keyboard focus. * If no overlay has keyboard focus, get returns null; set to null or {@link Uuid|Uuid.NULL} to * clear keyboard focus. diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h index 103b620254..d8f8a13cde 100644 --- a/libraries/animation/src/AnimationCache.h +++ b/libraries/animation/src/AnimationCache.h @@ -37,6 +37,10 @@ public: * API to manage animation cache resources. * @namespace AnimationCache * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/audio-client/src/AudioIOStats.h b/libraries/audio-client/src/AudioIOStats.h index 89db4942ec..45fcf365da 100644 --- a/libraries/audio-client/src/AudioIOStats.h +++ b/libraries/audio-client/src/AudioIOStats.h @@ -41,6 +41,10 @@ class AudioStreamStatsInterface : public QObject { /**jsdoc * @class AudioStats.AudioStreamStats + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} lossRate Read-only. * @property {number} lossCount Read-only. * @property {number} lossRateWindow Read-only. @@ -185,6 +189,10 @@ class AudioStatsInterface : public QObject { /**jsdoc * Audio stats from the client. * @namespace AudioStats + * + * @hifi-interface + * @hifi-client-entity + * * @property {number} pingMs Read-only. * @property {number} inputReadMsMax Read-only. * @property {number} inputUnplayedMsMax Read-only. diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index 172ec9411a..d60c5ba4ab 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -150,6 +150,7 @@ int InboundAudioStream::parseData(ReceivedMessage& message) { // fall through to OnTime case } + // FALLTHRU case SequenceNumberStats::OnTime: { // Packet is on time; parse its data to the ringbuffer if (message.getType() == PacketType::SilentAudioFrame diff --git a/libraries/audio/src/SoundCache.h b/libraries/audio/src/SoundCache.h index 039e815ff3..347f324353 100644 --- a/libraries/audio/src/SoundCache.h +++ b/libraries/audio/src/SoundCache.h @@ -29,6 +29,11 @@ public: * API to manage sound cache resources. * @namespace SoundCache * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h b/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h index 3c3858e2ba..5bc7357dd7 100644 --- a/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h +++ b/libraries/controllers/src/controllers/impl/MappingBuilderProxy.h @@ -54,6 +54,9 @@ class UserInputMapper; * * * @class MappingObject + * + * @hifi-interface + * @hifi-client-entity */ /**jsdoc diff --git a/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h b/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h index d33f3e3383..804709ebfa 100644 --- a/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h +++ b/libraries/controllers/src/controllers/impl/RouteBuilderProxy.h @@ -36,6 +36,9 @@ class ScriptingInterface; * types.

* * @class RouteObject + * + * @hifi-interface + * @hifi-client-entity */ // TODO migrate functionality to a RouteBuilder class and make the proxy defer to that diff --git a/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp index f33af1b580..59cd637ca0 100644 --- a/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp @@ -147,20 +147,21 @@ void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() { batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize())); batch.draw(gpu::TRIANGLE_STRIP, 4); }); - - // render stick head - auto jumpTransform = DependencyManager::get()->getPoint2DTransform(virtualPadManager.getJumpButtonPosition(), - _virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize); - render([&](gpu::Batch& batch) { - batch.enableStereo(false); - batch.setProjectionTransform(mat4()); - batch.setPipeline(_cursorPipeline); - batch.setResourceTexture(0, _virtualPadJumpBtnTexture); - batch.resetViewTransform(); - batch.setModelTransform(jumpTransform); - batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize())); - batch.draw(gpu::TRIANGLE_STRIP, 4); - }); + if (!virtualPadManager.getLeftVirtualPad()->isBeingTouched()) { + // render stick head + auto jumpTransform = DependencyManager::get()->getPoint2DTransform(virtualPadManager.getJumpButtonPosition(), + _virtualPadJumpBtnPixelSize, _virtualPadJumpBtnPixelSize); + render([&](gpu::Batch& batch) { + batch.enableStereo(false); + batch.setProjectionTransform(mat4()); + batch.setPipeline(_cursorPipeline); + batch.setResourceTexture(0, _virtualPadJumpBtnTexture); + batch.resetViewTransform(); + batch.setModelTransform(jumpTransform); + batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize())); + batch.draw(gpu::TRIANGLE_STRIP, 4); + }); + } } #endif Parent::compositeExtra(); diff --git a/libraries/display-plugins/src/display-plugins/CompositorHelper.h b/libraries/display-plugins/src/display-plugins/CompositorHelper.h index bc6ed63363..fb712c26fa 100644 --- a/libraries/display-plugins/src/display-plugins/CompositorHelper.h +++ b/libraries/display-plugins/src/display-plugins/CompositorHelper.h @@ -174,6 +174,10 @@ private: /**jsdoc * @namespace Reticle + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} allowMouseCapture * @property {number} depth * @property {Vec2} maximumPosition diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index 5e76d18515..8adb5138f2 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -94,6 +94,12 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra * Interface has displayed and so knows about. * * @namespace Entities + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {Uuid} keyboardFocusEntity - Get or set the {@link Entities.EntityType|Web} entity that has keyboard focus. * If no entity has keyboard focus, get returns null; set to null or {@link Uuid|Uuid.NULL} to * clear keyboard focus. diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index b56f367e0a..3149527216 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -1402,6 +1402,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c case PacketType::EntityAdd: isAdd = true; // fall through to next case + // FALLTHRU case PacketType::EntityPhysics: case PacketType::EntityEdit: { quint64 startDecode = 0, endDecode = 0; diff --git a/libraries/fbx/src/FBX.h b/libraries/fbx/src/FBX.h index a609d85fc8..ce3fc52c3a 100644 --- a/libraries/fbx/src/FBX.h +++ b/libraries/fbx/src/FBX.h @@ -298,6 +298,7 @@ public: bool hasSkeletonJoints; QVector meshes; + QVector scripts; QHash materials; diff --git a/libraries/fbx/src/FBXReader_Mesh.cpp b/libraries/fbx/src/FBXReader_Mesh.cpp index e8365e38b7..801edddb06 100644 --- a/libraries/fbx/src/FBXReader_Mesh.cpp +++ b/libraries/fbx/src/FBXReader_Mesh.cpp @@ -249,7 +249,7 @@ ExtractedMesh FBXReader::extractMesh(const FBXNode& object, unsigned int& meshIn indexToDirect = true; } } - if (indexToDirect && data.normalIndices.isEmpty()) { + if (indexToDirect && data.colorIndices.isEmpty()) { // hack to work around wacky Makehuman exports data.colorsByVertex = true; } diff --git a/libraries/fbx/src/FBXWriter.cpp b/libraries/fbx/src/FBXWriter.cpp index 511f253193..e6adff0df9 100644 --- a/libraries/fbx/src/FBXWriter.cpp +++ b/libraries/fbx/src/FBXWriter.cpp @@ -142,7 +142,6 @@ void FBXWriter::encodeFBXProperty(QDataStream& out, const QVariant& prop) { out << prop.toInt(); break; - encodeNode(out, FBXNode()); case QMetaType::Float: out.device()->write("F", 1); out << prop.toFloat(); diff --git a/libraries/fbx/src/FSTReader.cpp b/libraries/fbx/src/FSTReader.cpp index cc4a919445..d63a5b3cc4 100644 --- a/libraries/fbx/src/FSTReader.cpp +++ b/libraries/fbx/src/FSTReader.cpp @@ -84,7 +84,7 @@ void FSTReader::writeVariant(QBuffer& buffer, QVariantHash::const_iterator& it) QByteArray FSTReader::writeMapping(const QVariantHash& mapping) { static const QStringList PREFERED_ORDER = QStringList() << NAME_FIELD << TYPE_FIELD << SCALE_FIELD << FILENAME_FIELD - << TEXDIR_FIELD << JOINT_FIELD << FREE_JOINT_FIELD + << TEXDIR_FIELD << SCRIPT_FIELD << JOINT_FIELD << FREE_JOINT_FIELD << BLENDSHAPE_FIELD << JOINT_INDEX_FIELD; QBuffer buffer; buffer.open(QIODevice::WriteOnly); @@ -92,7 +92,7 @@ QByteArray FSTReader::writeMapping(const QVariantHash& mapping) { for (auto key : PREFERED_ORDER) { auto it = mapping.find(key); if (it != mapping.constEnd()) { - if (key == FREE_JOINT_FIELD) { // writeVariant does not handle strings added using insertMulti. + if (key == FREE_JOINT_FIELD || key == SCRIPT_FIELD) { // writeVariant does not handle strings added using insertMulti. for (auto multi : mapping.values(key)) { buffer.write(key.toUtf8()); buffer.write(" = "); @@ -187,6 +187,26 @@ FSTReader::ModelType FSTReader::predictModelType(const QVariantHash& mapping) { return ENTITY_MODEL; } +QVector FSTReader::getScripts(const QUrl& url, const QVariantHash& mapping) { + + auto fstMapping = mapping.isEmpty() ? downloadMapping(url.toString()) : mapping; + QVector scriptPaths; + if (!fstMapping.value(SCRIPT_FIELD).isNull()) { + auto scripts = fstMapping.values(SCRIPT_FIELD).toVector(); + for (auto &script : scripts) { + QString scriptPath = script.toString(); + if (QUrl(scriptPath).isRelative()) { + if (scriptPath.at(0) == '/') { + scriptPath = scriptPath.right(scriptPath.length() - 1); + } + scriptPath = url.resolved(QUrl(scriptPath)).toString(); + } + scriptPaths.push_back(scriptPath); + } + } + return scriptPaths; +} + QVariantHash FSTReader::downloadMapping(const QString& url) { QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkRequest networkRequest = QNetworkRequest(url); diff --git a/libraries/fbx/src/FSTReader.h b/libraries/fbx/src/FSTReader.h index 981bae4feb..4a8574f0cf 100644 --- a/libraries/fbx/src/FSTReader.h +++ b/libraries/fbx/src/FSTReader.h @@ -28,6 +28,7 @@ static const QString TRANSLATION_Z_FIELD = "tz"; static const QString JOINT_FIELD = "joint"; static const QString FREE_JOINT_FIELD = "freeJoint"; static const QString BLENDSHAPE_FIELD = "bs"; +static const QString SCRIPT_FIELD = "script"; class FSTReader { public: @@ -49,6 +50,8 @@ public: /// Predicts the type of model by examining the mapping static ModelType predictModelType(const QVariantHash& mapping); + static QVector getScripts(const QUrl& fstUrl, const QVariantHash& mapping = QVariantHash()); + static QString getNameFromType(ModelType modelType); static FSTReader::ModelType getTypeFromName(const QString& name); static QVariantHash downloadMapping(const QString& url); diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp index 2285b0e486..d1ab34da90 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendOutput.cpp @@ -46,10 +46,10 @@ void GLBackend::do_setFramebuffer(const Batch& batch, size_t paramOffset) { } void GLBackend::do_setFramebufferSwapChain(const Batch& batch, size_t paramOffset) { - auto swapChain = batch._swapChains.get(batch._params[paramOffset]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset]._uint)); if (swapChain) { auto index = batch._params[paramOffset + 1]._uint; - FramebufferPointer framebuffer = static_cast(swapChain.get())->get(index); + const auto& framebuffer = swapChain->get(index); setFramebuffer(framebuffer); } } diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp index 58fcc51605..91f1d8bb8c 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendPipeline.cpp @@ -268,7 +268,7 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si return; } - SwapChainPointer swapChain = batch._swapChains.get(batch._params[paramOffset + 0]._uint); + auto swapChain = std::static_pointer_cast(batch._swapChains.get(batch._params[paramOffset + 0]._uint)); if (!swapChain) { releaseResourceTexture(slot); @@ -276,9 +276,8 @@ void GLBackend::do_setResourceFramebufferSwapChainTexture(const Batch& batch, si } auto index = batch._params[paramOffset + 2]._uint; auto renderBufferSlot = batch._params[paramOffset + 3]._uint; - FramebufferPointer resourceFramebuffer = static_cast(swapChain.get())->get(index); - TexturePointer resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); - + auto resourceFramebuffer = swapChain->get(index); + auto resourceTexture = resourceFramebuffer->getRenderBuffer(renderBufferSlot); setResourceTexture(slot, resourceTexture); } diff --git a/libraries/gpu/src/gpu/ResourceSwapChain.h b/libraries/gpu/src/gpu/ResourceSwapChain.h index 7b46b35521..28c5ff2ed3 100644 --- a/libraries/gpu/src/gpu/ResourceSwapChain.h +++ b/libraries/gpu/src/gpu/ResourceSwapChain.h @@ -15,18 +15,18 @@ namespace gpu { class SwapChain { public: - SwapChain(unsigned int size = 2U) : _size{ size } {} + SwapChain(uint8_t size = 2U) : _size{ size } {} virtual ~SwapChain() {} void advance() { _frontIndex = (_frontIndex + 1) % _size; } - unsigned int getSize() const { return _size; } + uint8_t getSize() const { return _size; } protected: - unsigned int _size; - unsigned int _frontIndex{ 0U }; + const uint8_t _size; + uint8_t _frontIndex{ 0U }; }; typedef std::shared_ptr SwapChainPointer; @@ -41,16 +41,13 @@ namespace gpu { using Type = R; using TypePointer = std::shared_ptr; + using TypeConstPointer = std::shared_ptr; - ResourceSwapChain(unsigned int size = 2U) : SwapChain{ size } {} - - void reset() { - for (auto& ptr : _resources) { - ptr.reset(); + ResourceSwapChain(const std::vector& v) : SwapChain{ std::min((uint8_t)v.size(), MAX_SIZE) } { + for (size_t i = 0; i < _size; ++i) { + _resources[i] = v[i]; } } - - TypePointer& edit(unsigned int index) { return _resources[(index + _frontIndex) % _size]; } const TypePointer& get(unsigned int index) const { return _resources[(index + _frontIndex) % _size]; } private: diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h index e0bb39c855..b88c6345cf 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.h @@ -24,6 +24,9 @@ /**jsdoc * The experimental Graphics API (experimental) lets you query and manage certain graphics-related structures (like underlying meshes and textures) from scripting. * @namespace Graphics + * + * @hifi-interface + * @hifi-client-entity */ class GraphicsScriptingInterface : public QObject, public QScriptable, public Dependency { diff --git a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp index 957104bd30..7ee2135325 100644 --- a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp +++ b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.cpp @@ -43,6 +43,18 @@ void TouchscreenVirtualPadDevice::init() { _fixedPosition = true; // This should be config _viewTouchUpdateCount = 0; + resize(); + + auto& virtualPadManager = VirtualPad::Manager::instance(); + + if (_fixedPosition) { + virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled + } + + KeyboardMouseDevice::enableTouch(false); // Touch for view controls is managed by this plugin +} + +void TouchscreenVirtualPadDevice::resize() { QScreen* eventScreen = qApp->primaryScreen(); if (_screenDPIProvided != eventScreen->physicalDotsPerInch()) { _screenWidthCenter = eventScreen->size().width() / 2; @@ -59,12 +71,6 @@ void TouchscreenVirtualPadDevice::init() { auto& virtualPadManager = VirtualPad::Manager::instance(); setupControlsPositions(virtualPadManager, true); - - if (_fixedPosition) { - virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled - } - - KeyboardMouseDevice::enableTouch(false); // Touch for view controls is managed by this plugin } void TouchscreenVirtualPadDevice::setupControlsPositions(VirtualPad::Manager& virtualPadManager, bool force) { @@ -80,9 +86,10 @@ void TouchscreenVirtualPadDevice::setupControlsPositions(VirtualPad::Manager& vi virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint); // Jump button - float leftMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_LEFT_MARGIN_PIXELS / VirtualPad::Manager::DPI; + float jumpBtnPixelSize = _screenDPI * VirtualPad::Manager::JUMP_BTN_FULL_PIXELS / VirtualPad::Manager::DPI; + float rightMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_RIGHT_MARGIN_PIXELS / VirtualPad::Manager::DPI; float bottomMargin = _screenDPI * VirtualPad::Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS/ VirtualPad::Manager::DPI; - _jumpButtonPosition = glm::vec2( _jumpButtonRadius + leftMargin, eventScreen->size().height() - bottomMargin - _jumpButtonRadius - _extraBottomMargin); + _jumpButtonPosition = glm::vec2( eventScreen->size().width() - rightMargin - jumpBtnPixelSize, eventScreen->size().height() - bottomMargin - _jumpButtonRadius - _extraBottomMargin); virtualPadManager.setJumpButtonPosition(_jumpButtonPosition); } diff --git a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.h b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.h index 212b7633ec..e7e540b503 100644 --- a/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.h +++ b/libraries/input-plugins/src/input-plugins/TouchscreenVirtualPadDevice.h @@ -26,6 +26,7 @@ public: // Plugin functions virtual void init() override; + virtual void resize(); virtual bool isSupported() const override; virtual const QString getName() const override { return NAME; } diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index f17cdbb7e8..416920d43f 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -66,6 +66,7 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { auto mapping = FSTReader::readMapping(data); QString filename = mapping.value("filename").toString(); + if (filename.isNull()) { qCDebug(modelnetworking) << "Mapping file" << _url << "has no \"filename\" field"; finishedLoading(false); @@ -82,6 +83,14 @@ void GeometryMappingResource::downloadFinished(const QByteArray& data) { _textureBaseUrl = url.resolved(QUrl(".")); } + auto scripts = FSTReader::getScripts(_url, mapping); + if (scripts.size() > 0) { + mapping.remove(SCRIPT_FIELD); + for (auto &scriptPath : scripts) { + mapping.insertMulti(SCRIPT_FIELD, scriptPath); + } + } + auto animGraphVariant = mapping.value("animGraphUrl"); if (animGraphVariant.isValid()) { QUrl fstUrl(animGraphVariant.toString()); @@ -209,6 +218,14 @@ void GeometryReader::run() { throw QString("unsupported format"); } + // Add scripts to fbxgeometry + if (!_mapping.value(SCRIPT_FIELD).isNull()) { + QVariantList scripts = _mapping.values(SCRIPT_FIELD); + for (auto &script : scripts) { + fbxGeometry->scripts.push_back(script.toString()); + } + } + // Ensure the resource has not been deleted auto resource = _resource.toStrongRef(); if (!resource) { diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 438c5e0d65..5f35f058ed 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -144,6 +144,9 @@ public: * API to manage model cache resources. * @namespace ModelCache * + * @hifi-interface + * @hifi-client-entity + * * @property {number} numTotal - Total number of total resources. Read-only. * @property {number} numCached - Total number of cached resource. Read-only. * @property {number} sizeTotal - Size in bytes of all resources. Read-only. diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 0c0dbeefa4..4ea8a98976 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -148,14 +148,17 @@ public: // Properties are copied over from ResourceCache (see ResourceCache.h for reason). /**jsdoc - * API to manage texture cache resources. - * @namespace TextureCache - * - * @property {number} numTotal - Total number of total resources. Read-only. - * @property {number} numCached - Total number of cached resource. Read-only. - * @property {number} sizeTotal - Size in bytes of all resources. Read-only. - * @property {number} sizeCached - Size in bytes of all cached resources. Read-only. - */ + * API to manage texture cache resources. + * @namespace TextureCache + * + * @hifi-interface + * @hifi-client-entity + * + * @property {number} numTotal - Total number of total resources. Read-only. + * @property {number} numCached - Total number of cached resource. Read-only. + * @property {number} sizeTotal - Size in bytes of all resources. Read-only. + * @property {number} sizeCached - Size in bytes of all cached resources. Read-only. + */ // Functions are copied over from ResourceCache (see ResourceCache.h for reason). diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index f6264a19c4..049129b2ba 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -106,7 +106,11 @@ void AccountManager::logout() { } QString accountFileDir() { +#if defined(Q_OS_ANDROID) + return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/../files"; +#else return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); +#endif } QString accountFilePath() { diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 055d94c3b3..edb2992128 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -114,8 +114,6 @@ QUrl AddressManager::currentFacingPublicAddress() const { void AddressManager::loadSettings(const QString& lookupString) { #if defined(USE_GLES) && defined(Q_OS_WIN) handleUrl(QUrl("hifi://127.0.0.0"), LookupTrigger::StartupFromSettings); -#elif defined(Q_OS_ANDROID) - handleUrl(QUrl("hifi://pikachu/167.11,0.745735,181.529/0,0.887027,0,-0.461717"), LookupTrigger::StartupFromSettings); #else if (lookupString.isEmpty()) { handleUrl(currentAddressHandle.get(), LookupTrigger::StartupFromSettings); diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index 94eff46bda..94fb25812f 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -33,6 +33,11 @@ const QString GET_PLACE = "/api/v1/places/%1"; * The location API provides facilities related to your current location in the metaverse. * * @namespace location + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * * @property {Uuid} domainID - A UUID uniquely identifying the domain you're visiting. Is {@link Uuid|Uuid.NULL} if you're not * connected to the domain or are in a serverless domain. * Read-only. diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 31500be682..0660f02fd6 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -302,6 +302,7 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe } } else { NLPacket::LocalID sourceLocalID = Node::NULL_LOCAL_ID; + // check if we were passed a sourceNode hint or if we need to look it up if (!sourceNode) { // figure out which node this is from @@ -314,6 +315,7 @@ bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packe QUuid sourceID = sourceNode ? sourceNode->getUUID() : QUuid(); if (!sourceNode && + !isDomainServer() && sourceLocalID == getDomainLocalID() && packet.getSenderSockAddr() == getDomainSockAddr() && PacketTypeEnum::getDomainSourcedPackets().contains(headerType)) { @@ -608,6 +610,7 @@ bool LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID, ConnectionID newCo { QWriteLocker writeLocker(&_nodeMutex); + _localIDMap.unsafe_erase(matchingNode->getLocalID()); _nodeHash.unsafe_erase(it); } diff --git a/libraries/networking/src/MessagesClient.h b/libraries/networking/src/MessagesClient.h index 6ef3777d8c..f2ccfe33f4 100644 --- a/libraries/networking/src/MessagesClient.h +++ b/libraries/networking/src/MessagesClient.h @@ -37,6 +37,11 @@ * * * @namespace Messages + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class MessagesClient : public QObject, public Dependency { Q_OBJECT diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 7ba7cca96d..d3583687e8 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -750,6 +750,7 @@ bool Resource::handleFailedRequest(ResourceRequest::Result result) { qCDebug(networking) << "Timed out loading" << _url << "received" << _bytesReceived << "total" << _bytesTotal; // Fall through to other cases } + // FALLTHRU case ResourceRequest::Result::ServerUnavailable: { _attempts++; _attemptsRemaining--; @@ -768,6 +769,7 @@ bool Resource::handleFailedRequest(ResourceRequest::Result result) { } // fall through to final failure } + // FALLTHRU default: { _attemptsRemaining = 0; qCDebug(networking) << "Error loading " << _url << "attempt:" << _attempts << "attemptsRemaining:" << _attemptsRemaining; diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 8a77beefd4..e2df582aa3 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -89,6 +89,12 @@ class ScriptableResource : public QObject { /**jsdoc * @constructor Resource + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {string} url - URL of this resource. * @property {Resource.State} state - Current loading state. */ diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index c2bacd4949..68f21eea87 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -447,7 +447,12 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep) { // this case is prevented by setting _ownershipState to UNOWNABLE in EntityMotionState::ctor assert(!(_entity->getClientOnly() && _entity->getOwningAvatarID() != Physics::getSessionUUID())); - if (_entity->dynamicDataNeedsTransmit() || _entity->queryAACubeNeedsUpdate()) { + // shouldSendUpdate() sould NOT be triggering updates to maintain the queryAACube of dynamic entities. + // The server is supposed to predict the transform of such moving things. The client performs a "double prediction" + // where it predicts what the the server is doing, and only sends updates whent the entity's true transform + // differs significantly. That is what the remoteSimulationOutOfSync() logic is all about. + if (_entity->dynamicDataNeedsTransmit() || + (!_entity->getDynamic() && _entity->queryAACubeNeedsUpdate())) { return true; } diff --git a/libraries/physics/src/PhysicsDebugDraw.cpp b/libraries/physics/src/PhysicsDebugDraw.cpp new file mode 100644 index 0000000000..b2911219d5 --- /dev/null +++ b/libraries/physics/src/PhysicsDebugDraw.cpp @@ -0,0 +1,54 @@ +// +// PhysicsDebugDraw.cpp +// libraries/physics/src +// +// Created by Anthony Thibault 2018-4-18 +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "PhysicsDebugDraw.h" +#include "BulletUtil.h" +#include "PhysicsLogging.h" + +#include +#include + +void PhysicsDebugDraw::drawLine(const btVector3& from, const btVector3& to, const btVector3& color) { + DebugDraw::getInstance().drawRay(bulletToGLM(from), bulletToGLM(to), glm::vec4(color.getX(), color.getY(), color.getZ(), 1.0f)); +} + +void PhysicsDebugDraw::drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, + int lifeTime, const btVector3& color) { + + glm::vec3 normal, tangent, biNormal; + generateBasisVectors(bulletToGLM(normalOnB), Vectors::UNIT_X, normal, tangent, biNormal); + btVector3 u = glmToBullet(normal); + btVector3 v = glmToBullet(tangent); + btVector3 w = glmToBullet(biNormal); + + // x marks the spot, green is along the normal. + const float CONTACT_POINT_RADIUS = 0.1f; + const btVector3 GREEN(0.0f, 1.0f, 0.0f); + const btVector3 WHITE(1.0f, 1.0f, 1.0f); + drawLine(PointOnB - u * CONTACT_POINT_RADIUS, PointOnB + u * CONTACT_POINT_RADIUS, GREEN); + drawLine(PointOnB - v * CONTACT_POINT_RADIUS, PointOnB + v * CONTACT_POINT_RADIUS, WHITE); + drawLine(PointOnB - w * CONTACT_POINT_RADIUS, PointOnB + w * CONTACT_POINT_RADIUS, WHITE); +} + +void PhysicsDebugDraw::reportErrorWarning(const char* warningString) { + qCWarning(physics) << "BULLET:" << warningString; +} + +void PhysicsDebugDraw::draw3dText(const btVector3& location, const char* textString) { +} + +void PhysicsDebugDraw::setDebugMode(int debugMode) { + _debugDrawMode = debugMode; +} + +int PhysicsDebugDraw::getDebugMode() const { + return _debugDrawMode; +} diff --git a/libraries/physics/src/PhysicsDebugDraw.h b/libraries/physics/src/PhysicsDebugDraw.h new file mode 100644 index 0000000000..f653136474 --- /dev/null +++ b/libraries/physics/src/PhysicsDebugDraw.h @@ -0,0 +1,34 @@ +// +// PhysicsDebugDraw.h +// libraries/physics/src +// +// Created by Anthony Thibault 2018-4-18 +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +// http://bulletphysics.org/Bullet/BulletFull/classbtIDebugDraw.html + +#ifndef hifi_PhysicsDebugDraw_h +#define hifi_PhysicsDebugDraw_h + +#include +#include + +class PhysicsDebugDraw : public btIDebugDraw { +public: + using btIDebugDraw::drawLine; + virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color) override; + virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, + int lifeTime, const btVector3& color) override; + virtual void reportErrorWarning(const char* warningString) override; + virtual void draw3dText(const btVector3& location, const char* textString) override; + virtual void setDebugMode(int debugMode) override; + virtual int getDebugMode() const override; + +protected: + uint32_t _debugDrawMode; +}; + +#endif // hifi_PhysicsDebugDraw_h diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 7c2ad55405..50d516c256 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -22,6 +22,7 @@ #include "ObjectMotionState.h" #include "PhysicsEngine.h" #include "PhysicsHelpers.h" +#include "PhysicsDebugDraw.h" #include "ThreadSafeDynamicsWorld.h" #include "PhysicsLogging.h" @@ -49,6 +50,10 @@ void PhysicsEngine::init() { _broadphaseFilter = new btDbvtBroadphase(); _constraintSolver = new btSequentialImpulseConstraintSolver; _dynamicsWorld = new ThreadSafeDynamicsWorld(_collisionDispatcher, _broadphaseFilter, _constraintSolver, _collisionConfig); + _physicsDebugDraw.reset(new PhysicsDebugDraw()); + + // hook up debug draw renderer + _dynamicsWorld->setDebugDrawer(_physicsDebugDraw.get()); _ghostPairCallback = new btGhostPairCallback(); _dynamicsWorld->getPairCache()->setInternalGhostPairCallback(_ghostPairCallback); @@ -333,6 +338,10 @@ void PhysicsEngine::stepSimulation() { _hasOutgoingChanges = true; } + + if (_physicsDebugDraw->getDebugMode()) { + _dynamicsWorld->debugDrawWorld(); + } } class CProfileOperator { @@ -785,3 +794,49 @@ void PhysicsEngine::forEachDynamic(std::function act } } } + +void PhysicsEngine::setShowBulletWireframe(bool value) { + int mode = _physicsDebugDraw->getDebugMode(); + if (value) { + _physicsDebugDraw->setDebugMode(mode | btIDebugDraw::DBG_DrawWireframe); + } else { + _physicsDebugDraw->setDebugMode(mode & ~btIDebugDraw::DBG_DrawWireframe); + } +} + +void PhysicsEngine::setShowBulletAABBs(bool value) { + int mode = _physicsDebugDraw->getDebugMode(); + if (value) { + _physicsDebugDraw->setDebugMode(mode | btIDebugDraw::DBG_DrawAabb); + } else { + _physicsDebugDraw->setDebugMode(mode & ~btIDebugDraw::DBG_DrawAabb); + } +} + +void PhysicsEngine::setShowBulletContactPoints(bool value) { + int mode = _physicsDebugDraw->getDebugMode(); + if (value) { + _physicsDebugDraw->setDebugMode(mode | btIDebugDraw::DBG_DrawContactPoints); + } else { + _physicsDebugDraw->setDebugMode(mode & ~btIDebugDraw::DBG_DrawContactPoints); + } +} + +void PhysicsEngine::setShowBulletConstraints(bool value) { + int mode = _physicsDebugDraw->getDebugMode(); + if (value) { + _physicsDebugDraw->setDebugMode(mode | btIDebugDraw::DBG_DrawConstraints); + } else { + _physicsDebugDraw->setDebugMode(mode & ~btIDebugDraw::DBG_DrawConstraints); + } +} + +void PhysicsEngine::setShowBulletConstraintLimits(bool value) { + int mode = _physicsDebugDraw->getDebugMode(); + if (value) { + _physicsDebugDraw->setDebugMode(mode | btIDebugDraw::DBG_DrawConstraintLimits); + } else { + _physicsDebugDraw->setDebugMode(mode & ~btIDebugDraw::DBG_DrawConstraintLimits); + } +} + diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index 92d2e6885a..0dfe3a7a7c 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -30,6 +30,7 @@ const float HALF_SIMULATION_EXTENT = 512.0f; // meters class CharacterController; +class PhysicsDebugDraw; // simple class for keeping track of contacts class ContactKey { @@ -96,6 +97,12 @@ public: void removeDynamic(const QUuid dynamicID); void forEachDynamic(std::function actor); + void setShowBulletWireframe(bool value); + void setShowBulletAABBs(bool value); + void setShowBulletContactPoints(bool value); + void setShowBulletConstraints(bool value); + void setShowBulletConstraintLimits(bool value); + private: QList removeDynamicsForBody(btRigidBody* body); void addObjectToDynamicsWorld(ObjectMotionState* motionState); @@ -114,6 +121,7 @@ private: btSequentialImpulseConstraintSolver* _constraintSolver = NULL; ThreadSafeDynamicsWorld* _dynamicsWorld = NULL; btGhostPairCallback* _ghostPairCallback = NULL; + std::unique_ptr _physicsDebugDraw; ContactMap _contactMap; CollisionEvents _collisionEvents; diff --git a/libraries/render-utils/src/AnimDebugDraw.cpp b/libraries/render-utils/src/AnimDebugDraw.cpp index 7086b65f4c..eca500f36c 100644 --- a/libraries/render-utils/src/AnimDebugDraw.cpp +++ b/libraries/render-utils/src/AnimDebugDraw.cpp @@ -52,9 +52,9 @@ public: batch.setInputFormat(_vertexFormat); batch.setInputBuffer(0, _vertexBuffer, 0, sizeof(Vertex)); - batch.setIndexBuffer(gpu::UINT16, _indexBuffer, 0); + batch.setIndexBuffer(gpu::UINT32, _indexBuffer, 0); - auto numIndices = _indexBuffer->getSize() / sizeof(uint16_t); + auto numIndices = _indexBuffer->getSize() / sizeof(uint32_t); batch.drawIndexed(gpu::LINES, (int)numIndices); } @@ -135,9 +135,9 @@ AnimDebugDraw::AnimDebugDraw() : AnimDebugDrawData::Vertex { glm::vec3(1.0, 1.0f, 1.0f), toRGBA(0, 0, 255, 255) }, AnimDebugDrawData::Vertex { glm::vec3(1.0, 1.0f, 2.0f), toRGBA(0, 0, 255, 255) }, }); - static std::vector indices({ 0, 1, 2, 3, 4, 5 }); + static std::vector indices({ 0, 1, 2, 3, 4, 5 }); _animDebugDrawData->_vertexBuffer->setSubData(0, vertices); - _animDebugDrawData->_indexBuffer->setSubData(0, indices); + _animDebugDrawData->_indexBuffer->setSubData(0, indices); } AnimDebugDraw::~AnimDebugDraw() { @@ -425,9 +425,9 @@ void AnimDebugDraw::update() { data._isVisible = (numVerts > 0); - data._indexBuffer->resize(sizeof(uint16_t) * numVerts); + data._indexBuffer->resize(sizeof(uint32_t) * numVerts); for (int i = 0; i < numVerts; i++) { - data._indexBuffer->setSubData(i, (uint16_t)i);; + data._indexBuffer->setSubData(i, (uint32_t)i);; } }); scene->enqueueTransaction(transaction); diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index dd4bda2e37..c9aa1b8f71 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -189,7 +189,6 @@ const int AntialiasingPass_NextMapSlot = 4; Antialiasing::Antialiasing(bool isSharpenEnabled) : _isSharpenEnabled{ isSharpenEnabled } { - _antialiasingBuffers = std::make_shared(2U); } Antialiasing::~Antialiasing() { @@ -325,25 +324,25 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const int width = sourceBuffer->getWidth(); int height = sourceBuffer->getHeight(); - if (_antialiasingBuffers->get(0)) { - if (_antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) {// || (sourceBuffer && (_antialiasingBuffer->getRenderBuffer(1) != sourceBuffer->getRenderBuffer(0)))) { - _antialiasingBuffers->edit(0).reset(); - _antialiasingBuffers->edit(1).reset(); - _antialiasingTextures[0].reset(); - _antialiasingTextures[1].reset(); - } + if (_antialiasingBuffers && _antialiasingBuffers->get(0) && _antialiasingBuffers->get(0)->getSize() != uvec2(width, height)) { + _antialiasingBuffers.reset(); + _antialiasingTextures[0].reset(); + _antialiasingTextures[1].reset(); } - if (!_antialiasingBuffers->get(0)) { + + if (!_antialiasingBuffers) { + std::vector antiAliasingBuffers; // Link the antialiasing FBO to texture auto format = sourceBuffer->getRenderBuffer(0)->getTexelFormat(); auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP); for (int i = 0; i < 2; i++) { - auto& antiAliasingBuffer = _antialiasingBuffers->edit(i); - antiAliasingBuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("antialiasing")); + antiAliasingBuffers.emplace_back(gpu::Framebuffer::create("antialiasing")); + const auto& antiAliasingBuffer = antiAliasingBuffers.back(); _antialiasingTextures[i] = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, defaultSampler); antiAliasingBuffer->setRenderBuffer(0, _antialiasingTextures[i]); } + _antialiasingBuffers = std::make_shared(antiAliasingBuffers); } gpu::doInBatch("Antialiasing::run", args->_context, [&](gpu::Batch& batch) { diff --git a/libraries/script-engine/src/AssetScriptingInterface.h b/libraries/script-engine/src/AssetScriptingInterface.h index 5cb1136b74..eb9a628ae3 100644 --- a/libraries/script-engine/src/AssetScriptingInterface.h +++ b/libraries/script-engine/src/AssetScriptingInterface.h @@ -27,6 +27,11 @@ /**jsdoc * The Assets API allows you to communicate with the Asset Browser. * @namespace Assets + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class AssetScriptingInterface : public BaseAssetScriptingInterface, QScriptable { Q_OBJECT diff --git a/libraries/script-engine/src/Quat.h b/libraries/script-engine/src/Quat.h index e6e395d9bf..254757dece 100644 --- a/libraries/script-engine/src/Quat.h +++ b/libraries/script-engine/src/Quat.h @@ -35,6 +35,12 @@ * of gimbal lock. * @namespace Quat * @variation 0 + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property IDENTITY {Quat} { x: 0, y: 0, z: 0, w: 1 } : The identity rotation, i.e., no rotation. * Read-only. * @example Print the IDENTITY value. diff --git a/libraries/script-engine/src/RecordingScriptingInterface.h b/libraries/script-engine/src/RecordingScriptingInterface.h index 0e4f90b928..29d9b31049 100644 --- a/libraries/script-engine/src/RecordingScriptingInterface.h +++ b/libraries/script-engine/src/RecordingScriptingInterface.h @@ -25,6 +25,10 @@ class QScriptValue; /**jsdoc * @namespace Recording + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client */ class RecordingScriptingInterface : public QObject, public Dependency { Q_OBJECT diff --git a/libraries/script-engine/src/SceneScriptingInterface.h b/libraries/script-engine/src/SceneScriptingInterface.h index c69cd7090d..fdfbc6f6c0 100644 --- a/libraries/script-engine/src/SceneScriptingInterface.h +++ b/libraries/script-engine/src/SceneScriptingInterface.h @@ -112,6 +112,10 @@ namespace SceneScripting { /**jsdoc * @class Scene.Stage + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} backgroundMode * @property {Scene.Stage.KeyLight} keyLight * @property {Scene.Stage.Location} location @@ -171,6 +175,10 @@ namespace SceneScripting { /**jsdoc * @namespace Scene + * + * @hifi-interface + * @hifi-client-entity + * * @property {boolean} shouldRenderAvatars * @property {boolean} shouldRenderEntities * @property {Scene.Stage} stage diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index f0a13cc62b..4915a2dc8b 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -180,6 +180,21 @@ ScriptEngine::ScriptEngine(Context context, const QString& scriptContents, const // don't delete `ScriptEngines` until all `ScriptEngine`s are gone _scriptEngines(DependencyManager::get()) { + switch (_context) { + case Context::CLIENT_SCRIPT: + _type = Type::CLIENT; + break; + case Context::ENTITY_CLIENT_SCRIPT: + _type = Type::ENTITY_CLIENT; + break; + case Context::ENTITY_SERVER_SCRIPT: + _type = Type::ENTITY_SERVER; + break; + case Context::AGENT_SCRIPT: + _type = Type::AGENT; + break; + } + connect(this, &QScriptEngine::signalHandlerException, this, [this](const QScriptValue& exception) { if (hasUncaughtException()) { // the engine's uncaughtException() seems to produce much better stack traces here diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 63a4ba4f90..7a9af2278c 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -89,6 +89,12 @@ public: /**jsdoc * @namespace Script + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {string} context */ class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvider { @@ -103,6 +109,14 @@ public: AGENT_SCRIPT }; + enum Type { + CLIENT, + ENTITY_CLIENT, + ENTITY_SERVER, + AGENT, + AVATAR + }; + static int processLevelMaxRetries; ScriptEngine(Context context, const QString& scriptContents = NO_SCRIPT, const QString& fileNameString = QString("about:ScriptEngine")); ~ScriptEngine(); @@ -493,6 +507,9 @@ public: */ Q_INVOKABLE QUuid generateUUID() { return QUuid::createUuid(); } + void setType(Type type) { _type = type; }; + Type getType() { return _type; }; + bool isFinished() const { return _isFinished; } // used by Application and ScriptWidget bool isRunning() const { return _isRunning; } // used by ScriptWidget @@ -724,6 +741,7 @@ protected: void callWithEnvironment(const EntityItemID& entityID, const QUrl& sandboxURL, QScriptValue function, QScriptValue thisObject, QScriptValueList args); Context _context; + Type _type; QString _scriptContents; QString _parentURL; std::atomic _isFinished { false }; diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index a788cd9f0e..f2ed296b63 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -427,11 +427,13 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { if (_scriptEnginesHash.contains(scriptURL)) { ScriptEnginePointer scriptEngine = _scriptEnginesHash[scriptURL]; if (restart) { + bool isUserLoaded = scriptEngine->isUserLoaded(); + ScriptEngine::Type type = scriptEngine->getType(); auto scriptCache = DependencyManager::get(); scriptCache->deleteScript(scriptURL); connect(scriptEngine.data(), &ScriptEngine::finished, - this, [this](QString scriptName, ScriptEnginePointer engine) { - reloadScript(scriptName); + this, [this, isUserLoaded, type](QString scriptName, ScriptEnginePointer engine) { + reloadScript(scriptName, isUserLoaded)->setType(type); }); } scriptEngine->stop(); diff --git a/libraries/script-engine/src/ScriptEngines.h b/libraries/script-engine/src/ScriptEngines.h index 1200168420..376bae4827 100644 --- a/libraries/script-engine/src/ScriptEngines.h +++ b/libraries/script-engine/src/ScriptEngines.h @@ -29,6 +29,10 @@ class ScriptEngine; /**jsdoc * @namespace ScriptDiscoveryService + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} debugScriptUrl * @property {string} defaultScriptsPath * @property {ScriptsModel} scriptsModel @@ -259,7 +263,7 @@ protected slots: protected: friend class ScriptEngine; - void reloadScript(const QString& scriptName) { loadScript(scriptName, true, false, false, true); } + ScriptEnginePointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); } void removeScriptEngine(ScriptEnginePointer); void onScriptEngineLoaded(const QString& scriptFilename); void onScriptEngineError(const QString& scriptFilename); diff --git a/libraries/script-engine/src/ScriptUUID.h b/libraries/script-engine/src/ScriptUUID.h index 303a871d1d..9b61f451c5 100644 --- a/libraries/script-engine/src/ScriptUUID.h +++ b/libraries/script-engine/src/ScriptUUID.h @@ -23,6 +23,12 @@ * hexadecimal digits. * * @namespace Uuid + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property NULL {Uuid} The null UUID, {00000000-0000-0000-0000-000000000000}. */ diff --git a/libraries/script-engine/src/ScriptsModel.h b/libraries/script-engine/src/ScriptsModel.h index a4ffc192f9..2466347baa 100644 --- a/libraries/script-engine/src/ScriptsModel.h +++ b/libraries/script-engine/src/ScriptsModel.h @@ -68,6 +68,9 @@ public: *

Has properties and functions below in addition to those of * http://doc.qt.io/qt-5/qabstractitemmodel.html.

* @class ScriptsModel + * + * @hifi-interface + * @hifi-client-entity */ class ScriptsModel : public QAbstractItemModel { Q_OBJECT diff --git a/libraries/script-engine/src/ScriptsModelFilter.h b/libraries/script-engine/src/ScriptsModelFilter.h index 26efde02e8..05a76334bb 100644 --- a/libraries/script-engine/src/ScriptsModelFilter.h +++ b/libraries/script-engine/src/ScriptsModelFilter.h @@ -20,6 +20,9 @@ *

Has properties and functions per * http://doc.qt.io/qt-5/qsortfilterproxymodel.html.

* @class ScriptsModelFilter + * + * @hifi-interface + * @hifi-client-entity */ class ScriptsModelFilter : public QSortFilterProxyModel { Q_OBJECT diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 6728c471f6..f214c3f11c 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -18,7 +18,12 @@ /**jsdoc * @namespace Users - * @property {boolean} canKick - true if the domain server allows the node or avatar to kick (ban) avatars, + * + * @hifi-interface + * @hifi-client-entity + * @hifi-assignment-client + * + * @property {boolean} canKick - true if the domain server allows the node or avatar to kick (ban) avatars, * otherwise false. Read-only. * @property {boolean} requestsDomainListData - true if the avatar requests extra data from the mixers (such as * positional data of an avatar you've ignored). Read-only. diff --git a/libraries/script-engine/src/Vec3.h b/libraries/script-engine/src/Vec3.h index 635f2a530c..eb9438c5c2 100644 --- a/libraries/script-engine/src/Vec3.h +++ b/libraries/script-engine/src/Vec3.h @@ -47,6 +47,12 @@ * * @namespace Vec3 * @variation 0 + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @property {Vec3} UNIT_X - { x: 1, y: 0, z: 0 } : Unit vector in the x-axis direction. Read-only. * @property {Vec3} UNIT_Y - { x: 0, y: 1, z: 0 } : Unit vector in the y-axis direction. Read-only. * @property {Vec3} UNIT_Z - { x: 0, y: 0, z: 1 } : Unit vector in the z-axis direction. Read-only. diff --git a/libraries/shared/src/DebugDraw.h b/libraries/shared/src/DebugDraw.h index 64327585fb..7dd19415c9 100644 --- a/libraries/shared/src/DebugDraw.h +++ b/libraries/shared/src/DebugDraw.h @@ -25,6 +25,11 @@ * Helper functions to render ephemeral debug markers and lines. * DebugDraw markers and lines are only visible locally, they are not visible by other users. * @namespace DebugDraw + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client */ class DebugDraw : public QObject { Q_OBJECT diff --git a/libraries/shared/src/Gzip.cpp b/libraries/shared/src/Gzip.cpp index a77f459fc9..25e214fffb 100644 --- a/libraries/shared/src/Gzip.cpp +++ b/libraries/shared/src/Gzip.cpp @@ -60,6 +60,7 @@ bool gunzip(QByteArray source, QByteArray &destination) { switch (status) { case Z_NEED_DICT: status = Z_DATA_ERROR; + // FALLTHRU case Z_DATA_ERROR: case Z_MEM_ERROR: case Z_STREAM_ERROR: diff --git a/libraries/shared/src/PathUtils.h b/libraries/shared/src/PathUtils.h index d879ac968d..fc933b6b8c 100644 --- a/libraries/shared/src/PathUtils.h +++ b/libraries/shared/src/PathUtils.h @@ -22,6 +22,10 @@ * The Paths API provides absolute paths to the scripts and resources directories. * * @namespace Paths + * + * @hifi-interface + * @hifi-client-entity + * * @deprecated The Paths API is deprecated. Use {@link Script.resolvePath} and {@link Script.resourcesPath} instead. * @readonly * @property {string} defaultScripts - The path to the scripts directory. Read-only. diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 689d1a3f42..467d6374a5 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -361,6 +361,12 @@ using MeshPointer = std::shared_ptr; /**jsdoc * A handle for a mesh in an entity, such as returned by {@link Entities.getMeshes}. * @class MeshProxy + * + * @hifi-interface + * @hifi-client-entity + * @hifi-server-entity + * @hifi-assignment-client + * * @deprecated Use the {@link Graphics} API instead. */ class MeshProxy : public QObject { diff --git a/libraries/shared/src/shared/Camera.h b/libraries/shared/src/shared/Camera.h index ea2e9cddab..32e753d0f9 100644 --- a/libraries/shared/src/shared/Camera.h +++ b/libraries/shared/src/shared/Camera.h @@ -40,6 +40,10 @@ class Camera : public QObject { * The Camera API provides access to the "camera" that defines your view in desktop and HMD display modes. * * @namespace Camera + * + * @hifi-interface + * @hifi-client-entity + * * @property position {Vec3} The position of the camera. You can set this value only when the camera is in independent mode. * @property orientation {Quat} The orientation of the camera. You can set this value only when the camera is in independent * mode. diff --git a/libraries/ui/src/VirtualPadManager.cpp b/libraries/ui/src/VirtualPadManager.cpp index c786110bdf..dae19b52c2 100644 --- a/libraries/ui/src/VirtualPadManager.cpp +++ b/libraries/ui/src/VirtualPadManager.cpp @@ -39,9 +39,9 @@ namespace VirtualPad { const float Manager::BASE_MARGIN_PIXELS = 59.0f; const float Manager::STICK_RADIUS_PIXELS = 105.0f; const float Manager::JUMP_BTN_TRIMMED_RADIUS_PIXELS = 67.0f; - const float Manager::JUMP_BTN_FULL_PIXELS = 134.0f; - const float Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS = 67.0f; - const float Manager::JUMP_BTN_LEFT_MARGIN_PIXELS = 547.0f; + const float Manager::JUMP_BTN_FULL_PIXELS = 164.0f; + const float Manager::JUMP_BTN_BOTTOM_MARGIN_PIXELS = 80.0f; + const float Manager::JUMP_BTN_RIGHT_MARGIN_PIXELS = 13.0f; Manager::Manager() { diff --git a/libraries/ui/src/VirtualPadManager.h b/libraries/ui/src/VirtualPadManager.h index 68b3d4f10f..6f7fbcc921 100644 --- a/libraries/ui/src/VirtualPadManager.h +++ b/libraries/ui/src/VirtualPadManager.h @@ -54,7 +54,7 @@ namespace VirtualPad { static const float JUMP_BTN_TRIMMED_RADIUS_PIXELS; static const float JUMP_BTN_FULL_PIXELS; static const float JUMP_BTN_BOTTOM_MARGIN_PIXELS; - static const float JUMP_BTN_LEFT_MARGIN_PIXELS; + static const float JUMP_BTN_RIGHT_MARGIN_PIXELS; private: Instance _leftVPadInstance; diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h index bab15fc7b6..e74b846f02 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.h +++ b/libraries/ui/src/ui/TabletScriptingInterface.h @@ -40,6 +40,9 @@ class OffscreenQmlSurface; /**jsdoc * @namespace Tablet + * + * @hifi-interface + * @hifi-client-entity */ class TabletScriptingInterface : public QObject, public Dependency { Q_OBJECT @@ -176,6 +179,10 @@ Q_DECLARE_METATYPE(TabletButtonsProxyModel*); /**jsdoc * @class TabletProxy + * + * @hifi-interface + * @hifi-client-entity + * * @property {string} name - Name of this tablet. Read-only. * @property {boolean} toolbarMode - Used to transition this tablet into and out of toolbar mode. * When tablet is in toolbar mode, all its buttons will appear in a floating toolbar. @@ -410,6 +417,10 @@ Q_DECLARE_METATYPE(TabletProxy*); /**jsdoc * @class TabletButtonProxy + * + * @hifi-interface + * @hifi-client-entity + * * @property {Uuid} uuid - Uniquely identifies this button. Read-only. * @property {TabletButtonProxy.ButtonProperties} properties */ diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index 11aee6a9d2..98fbb4b1a7 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -14,7 +14,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", - "system/+android/bottombar.js", + "system/+android/actionbar.js", "system/+android/audio.js" , "system/+android/modes.js", "system/+android/stats.js"/*, diff --git a/scripts/system/+android/actionbar.js b/scripts/system/+android/actionbar.js new file mode 100644 index 0000000000..1f0872d5ee --- /dev/null +++ b/scripts/system/+android/actionbar.js @@ -0,0 +1,53 @@ +"use strict"; +// +// backbutton.js +// scripts/system/+android +// +// Created by Gabriel Calero & Cristian Duarte on Apr 06, 2018 +// Copyright 2018 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +(function() { // BEGIN LOCAL_SCOPE + +var actionbar; +var backButton; + +var logEnabled = true; + +function printd(str) { + if (logEnabled) + print("[actionbar.js] " + str); +} + +function init() { + actionbar = new QmlFragment({ + qml: "hifi/ActionBar.qml" + }); + backButton = actionbar.addButton({ + icon: "icons/+android/backward.svg", + activeIcon: "icons/+android/backward.svg", + text: "", + bgOpacity: 0.0, + hoverBgOpacity: 0.0, + activeBgOpacity: 0.0 + }); + + backButton.clicked.connect(onBackPressed); +} + +function onBackPressed() { + App.openAndroidActivity("Home"); +} + + +Script.scriptEnding.connect(function() { + if(backButton) { + backButton.clicked.disconnect(onBackPressed); + } +}); + +init(); + +}()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/audio.js b/scripts/system/+android/audio.js index 955f74d63a..4d6d8db008 100644 --- a/scripts/system/+android/audio.js +++ b/scripts/system/+android/audio.js @@ -32,8 +32,9 @@ function init() { activeIcon: "icons/mic-mute-a.svg", text: "", bgOpacity: 0.0, - activeBgOpacity: 0.0, - bgColor: "#FFFFFF" + hoverBgOpacity: 0.0, + activeHoverBgOpacity: 0.0, + activeBgOpacity: 0.0 }); onMuteToggled(); diff --git a/scripts/system/+android/avatarSelection.js b/scripts/system/+android/avatarSelection.js deleted file mode 100644 index 2946e541b5..0000000000 --- a/scripts/system/+android/avatarSelection.js +++ /dev/null @@ -1,164 +0,0 @@ -"use strict"; -// -// avatarSelection.js -// scripts/system/ -// -// Created by Gabriel Calero & Cristian Duarte on 21 Sep 2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var window; - -var logEnabled = true; -var isVisible = false; - -function printd(str) { - if (logEnabled) - print("[avatarSelection.js] " + str); -} - -function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. - var data; - printd("fromQml " + JSON.stringify(message)); - switch (message.method) { - case 'selectAvatar': - // use this message.params.avatarUrl - printd("Selected Avatar: [" + message.params.avatarUrl + "]"); - App.askBeforeSetAvatarUrl(message.params.avatarUrl); - break; - case 'openAvatarMarket': - // good - App.openUrl("https://metaverse.highfidelity.com/marketplace?category=avatars"); - break; - case 'hide': - Controller.setVPadHidden(false); - module.exports.hide(); - module.exports.onHidden(); - break; - default: - print('[avatarSelection.js] Unrecognized message from avatarSelection.qml:', JSON.stringify(message)); - } -} - -function sendToQml(message) { - if (!window) { - print("[avatarSelection.js] There is no window object"); - return; - } - window.sendToQml(message); -} - -function refreshSelected(currentAvatarURL) { - sendToQml({ - type: "refreshSelected", - selectedAvatarUrl: currentAvatarURL - }); - - sendToQml({ - type: "showAvatars" - }); -} - -function init() { - if (!window) { - print("[avatarSelection.js] There is no window object for init()"); - return; - } - var DEFAULT_AVATAR_URL = "http://mpassets.highfidelity.com/7fe80a1e-f445-4800-9e89-40e677b03bee-v3/mannequin.fst"; - sendToQml({ - type: "addAvatar", - name: "Wooden Mannequin", - thumbnailUrl: "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/7fe80a1e-f445-4800-9e89-40e677b03bee/thumbnail/hifi-mp-7fe80a1e-f445-4800-9e89-40e677b03bee.jpg", - avatarUrl: DEFAULT_AVATAR_URL - }); - sendToQml({ - type: "addAvatar", - name: "Cody", - thumbnailUrl: "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/8c859fca-4cbd-4e82-aad1-5f4cb0ca5d53/thumbnail/hifi-mp-8c859fca-4cbd-4e82-aad1-5f4cb0ca5d53.jpg", - avatarUrl: "http://mpassets.highfidelity.com/8c859fca-4cbd-4e82-aad1-5f4cb0ca5d53-v1/cody.fst" - }); - sendToQml({ - type: "addAvatar", - name: "Mixamo Will", - thumbnailUrl: "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/d029ae8d-2905-4eb7-ba46-4bd1b8cb9d73/thumbnail/hifi-mp-d029ae8d-2905-4eb7-ba46-4bd1b8cb9d73.jpg", - avatarUrl: "http://mpassets.highfidelity.com/d029ae8d-2905-4eb7-ba46-4bd1b8cb9d73-v1/4618d52e711fbb34df442b414da767bb.fst" - }); - sendToQml({ - type: "addAvatar", - name: "Albert", - thumbnailUrl: "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/1e57c395-612e-4acd-9561-e79dbda0bc49/thumbnail/hifi-mp-1e57c395-612e-4acd-9561-e79dbda0bc49.jpg", - avatarUrl: "http://mpassets.highfidelity.com/1e57c395-612e-4acd-9561-e79dbda0bc49-v1/albert.fst" - }); - /* We need to implement the wallet, so let's skip this for the moment - sendToQml({ - type: "addExtraOption", - showName: "More choices", - thumbnailUrl: "../../../images/moreAvatars.png", - methodNameWhenClicked: "openAvatarMarket", - actionText: "MARKETPLACE" - }); - */ - var currentAvatarURL = Settings.getValue('Avatar/fullAvatarURL', DEFAULT_AVATAR_URL); - printd("Default Avatar: [" + DEFAULT_AVATAR_URL + "]"); - printd("Current Avatar: [" + currentAvatarURL + "]"); - if (!currentAvatarURL || 0 === currentAvatarURL.length) { - currentAvatarURL = DEFAULT_AVATAR_URL; - } - refreshSelected(currentAvatarURL); -} - -module.exports = { - init: function() { - window = new QmlFragment({ - qml: "hifi/avatarSelection.qml", - visible: false - }); - if (window) { - window.fromQml.connect(fromQml); - } - init(); - }, - show: function() { - Controller.setVPadHidden(true); - if (window) { - window.setVisible(true); - isVisible = true; - } - }, - hide: function() { - Controller.setVPadHidden(false); - if (window) { - window.setVisible(false); - } - isVisible = false; - }, - destroy: function() { - Controller.setVPadHidden(false); - if (window) { - window.fromQml.disconnect(fromQml); - window.close(); - window = null; - } - }, - isVisible: function() { - return isVisible; - }, - width: function() { - return window ? window.size.x : 0; - }, - height: function() { - return window ? window.size.y : 0; - }, - position: function() { - return window && isVisible ? window.position : null; - }, - refreshSelectedAvatar: function(currentAvatarURL) { - refreshSelected(currentAvatarURL); - }, - onHidden: function() { - Controller.setVPadHidden(false); - } -}; diff --git a/scripts/system/+android/bottombar.js b/scripts/system/+android/bottombar.js deleted file mode 100644 index 3435edb548..0000000000 --- a/scripts/system/+android/bottombar.js +++ /dev/null @@ -1,267 +0,0 @@ -"use strict"; -// -// bottombar.js -// scripts/system/ -// -// Created by Gabriel Calero & Cristian Duarte on Jan 18, 2018 -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -(function() { // BEGIN LOCAL_SCOPE - -var bottombar; -var bottomHudOptionsBar; -var gotoBtn; -var avatarBtn; -var bubbleBtn; -var loginBtn; - -var gotoScript = Script.require('./goto.js'); -var avatarSelection = Script.require('./avatarSelection.js'); - -var logEnabled = false; - -function printd(str) { - if (logEnabled) { - print("[bottombar.js] " + str); - } -} - -function init() { - gotoScript.init(); - gotoScript.setOnShownChange(function (shown) { - if (shown) { - showAddressBar(); - } else { - hideAddressBar(); - } - }); - avatarSelection.init(); - App.fullAvatarURLChanged.connect(processedNewAvatar); - - setupBottomBar(); - setupBottomHudOptionsBar(); - - raiseBottomBar(); - - GlobalServices.connected.connect(handleLogin); - GlobalServices.disconnected.connect(handleLogout); -} - -function shutdown() { - App.fullAvatarURLChanged.disconnect(processedNewAvatar); -} - -function setupBottomBar() { - bottombar = new QmlFragment({ - qml: "hifi/bottombar.qml" - }); - - bottombar.fromQml.connect(function(message) { - switch (message.method) { - case 'hide': - lowerBottomBar(); - break; - default: - print('[bottombar.js] Unrecognized message from bottomHud.qml:', JSON.stringify(message)); - } - }); - - avatarBtn = bottombar.addButton({ - icon: "icons/avatar-i.svg", - activeIcon: "icons/avatar-a.svg", - bgOpacity: 0, - height: 240, - width: 294, - hoverBgOpacity: 0, - activeBgOpacity: 0, - activeHoverBgOpacity: 0, - iconSize: 108, - textSize: 45, - text: "AVATAR" - }); - avatarBtn.clicked.connect(function() { - printd("Avatar button clicked"); - if (!avatarSelection.isVisible()) { - showAvatarSelection(); - } else { - hideAvatarSelection(); - } - }); - avatarSelection.onHidden = function() { - if (avatarBtn) { - avatarBtn.isActive = false; - } - }; - - gotoBtn = bottombar.addButton({ - icon: "icons/goto-i.svg", - activeIcon: "icons/goto-a.svg", - bgOpacity: 0, - hoverBgOpacity: 0, - activeBgOpacity: 0, - activeHoverBgOpacity: 0, - height: 240, - width: 294, - iconSize: 108, - textSize: 45, - text: "GO TO" - }); - - gotoBtn.clicked.connect(function() { - if (!gotoScript.isVisible()) { - showAddressBar(); - } else { - hideAddressBar(); - } - }); - - bubbleBtn = bottombar.addButton({ - icon: "icons/bubble-i.svg", - activeIcon: "icons/bubble-a.svg", - bgOpacity: 0, - hoverBgOpacity: 0, - activeBgOpacity: 0, - activeHoverBgOpacity: 0, - height: 240, - width: 294, - iconSize: 108, - textSize: 45, - text: "BUBBLE" - }); - - bubbleBtn.editProperties({isActive: Users.getIgnoreRadiusEnabled()}); - - bubbleBtn.clicked.connect(function() { - Users.toggleIgnoreRadius(); - bubbleBtn.editProperties({isActive: Users.getIgnoreRadiusEnabled()}); - }); - - loginBtn = bottombar.addButton({ - icon: "icons/login-i.svg", - activeIcon: "icons/login-a.svg", - height: 240, - width: 294, - iconSize: 108, - textSize: 45, - text: Account.isLoggedIn() ? "LOG OUT" : "LOG IN" - }); - loginBtn.clicked.connect(function() { - if (!Account.isLoggedIn()) { - Account.checkAndSignalForAccessToken(); - } else { - Menu.triggerOption("Login / Sign Up"); - } - }); - - // TODO: setup all the buttons or provide a dynamic interface - - raiseBottomBar(); - - -} - -var setupBottomHudOptionsBar = function() { - var bottomHud = new QmlFragment({ - qml: "hifi/bottomHudOptions.qml" - }); - - bottomHudOptionsBar = { - show: function() { - bottomHud.setVisible(true); - }, - hide: function() { - bottomHud.setVisible(false); - }, - qmlFragment: bottomHud - }; - bottomHud.fromQml.connect( - function(message) { - switch (message.method) { - case 'showUpBar': - printd('[bottombar.js] showUpBar message from bottomHudOptions.qml: ', JSON.stringify(message)); - raiseBottomBar(); - break; - default: - print('[bottombar.js] Unrecognized message from bottomHudOptions.qml:', JSON.stringify(message)); - } - } - ); -} - -function lowerBottomBar() { - if (bottombar) { - bottombar.setVisible(false); - } - if (bottomHudOptionsBar) { - bottomHudOptionsBar.show(); - } - Controller.setVPadExtraBottomMargin(0); -} - -function raiseBottomBar() { - print('[bottombar.js] raiseBottomBar begin'); - if (bottombar) { - bottombar.setVisible(true); - } - if (bottomHudOptionsBar) { - bottomHudOptionsBar.hide(); - } - Controller.setVPadExtraBottomMargin(255); // Height in bottombar.qml - print('[bottombar.js] raiseBottomBar end'); -} - -function showAddressBar() { - gotoScript.show(); - gotoBtn.isActive = true; -} - -function hideAddressBar() { - gotoScript.hide(); - gotoBtn.isActive = false; -} - -function showAvatarSelection() { - avatarSelection.show(); - avatarBtn.isActive = true; -} - -function hideAvatarSelection() { - avatarSelection.hide(); - avatarBtn.isActive = false; -} - -// TODO: Move to avatarSelection.js and make it possible to hide the window from there AND switch the button state here too -function processedNewAvatar(url, modelName) { - avatarSelection.refreshSelectedAvatar(url); - hideAvatarSelection(); -} - -function handleLogin() { - Script.setTimeout(function() { - if (Account.isLoggedIn()) { - MyAvatar.displayName=Account.getUsername(); - } - }, 2000); - if (loginBtn) { - loginBtn.editProperties({text: "LOG OUT"}); - } -} -function handleLogout() { - MyAvatar.displayName=""; - if (loginBtn) { - loginBtn.editProperties({text: "LOG IN"}); - } -} - -Script.scriptEnding.connect(function () { - shutdown(); - GlobalServices.connected.disconnect(handleLogin); - GlobalServices.disconnected.disconnect(handleLogout); -}); - -init(); - -}()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/goto.js b/scripts/system/+android/goto.js deleted file mode 100644 index 2019af9077..0000000000 --- a/scripts/system/+android/goto.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -// -// goto-android.js -// scripts/system/ -// -// Created by Gabriel Calero & Cristian Duarte on 12 Sep 2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var window; - - -var logEnabled = false; -function printd(str) { - if (logEnabled) - print("[goto-android.js] " + str); -} - -function init() { -} - -function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. - switch (message.method) { - case 'shownChanged': - if (notifyShownChange) { - notifyShownChange(message.params.shown); - } ; - break; - case 'hide': - module.exports.hide(); - module.exports.onHidden(); - break; - default: - print('[goto-android.js] Unrecognized message from AddressBarDialog.qml:', JSON.stringify(message)); - } -} - -function sendToQml(message) { - window.sendToQml(message); -} - -var isVisible = false; -var notifyShownChange; -module.exports = { - init: function() { - window = new QmlFragment({ - qml: "AddressBarDialog.qml", - visible: false - }); - }, - show: function() { - Controller.setVPadHidden(true); - if (window) { - window.fromQml.connect(fromQml); - window.setVisible(true); - isVisible = true; - } - }, - hide: function() { - Controller.setVPadHidden(false); - if (window) { - window.fromQml.disconnect(fromQml); - window.setVisible(false); - } - isVisible = false; - }, - destroy: function() { - if (window) { - window.close(); - window = null; - } - }, - isVisible: function() { - return isVisible; - }, - width: function() { - return window ? window.size.x : 0; - }, - height: function() { - return window ? window.size.y : 0; - }, - position: function() { - return window && isVisible ? window.position : null; - }, - setOnShownChange: function(f) { - notifyShownChange = f; - }, - onHidden: function() { } - - -}; - -init(); diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js index c41ae1f327..f5b3609c26 100644 --- a/scripts/system/+android/modes.js +++ b/scripts/system/+android/modes.js @@ -11,15 +11,21 @@ // (function() { // BEGIN LOCAL_SCOPE -var modesbar; -var modesButtons; -var currentSelectedBtn; +var modeButton; +var currentMode; +var barQml; var SETTING_CURRENT_MODE_KEY = 'Android/Mode'; var MODE_VR = "VR", MODE_RADAR = "RADAR", MODE_MY_VIEW = "MY VIEW"; var DEFAULT_MODE = MODE_MY_VIEW; -var logEnabled = true; +var nextMode = {}; +nextMode[MODE_RADAR]=MODE_MY_VIEW; +nextMode[MODE_MY_VIEW]=MODE_RADAR; +var modeLabel = {}; +modeLabel[MODE_RADAR]="TOP VIEW"; +modeLabel[MODE_MY_VIEW]="MY VIEW"; +var logEnabled = false; var radar = Script.require('./radar.js'); var uniqueColor = Script.require('./uniqueColor.js'); @@ -32,89 +38,35 @@ function printd(str) { function init() { radar.setUniqueColor(uniqueColor); radar.init(); - setupModesBar(); + + barQml = new QmlFragment({ + qml: "hifi/modesbar.qml" + }); + modeButton = barQml.addButton({ + icon: "icons/myview-a.svg", + activeBgOpacity: 0.0, + hoverBgOpacity: 0.0, + activeHoverBgOpacity: 0.0, + text: "MODE", + height:240, + bottomMargin: 16, + textSize: 38, + fontFamily: "Raleway", + fontBold: true + + }); + + switchToMode(getCurrentModeSetting()); + + modeButton.clicked.connect(function() { + switchToMode(nextMode[currentMode]); + }); } function shutdown() { } -function setupModesBar() { - - var bar = new QmlFragment({ - qml: "hifi/modesbar.qml" - }); - var buttonRadarMode = bar.addButton({ - icon: "icons/radar-i.svg", - activeIcon: "icons/radar-a.svg", - hoverIcon: "icons/radar-a.svg", - activeBgOpacity: 0.0, - hoverBgOpacity: 0.0, - activeHoverBgOpacity: 0.0, - text: "RADAR", - height:240, - bottomMargin: 6, - textSize: 45 - }); - var buttonMyViewMode = bar.addButton({ - icon: "icons/myview-i.svg", - activeIcon: "icons/myview-a.svg", - hoverIcon: "icons/myview-a.svg", - activeBgOpacity: 0.0, - hoverBgOpacity: 0.0, - activeHoverBgOpacity: 0.0, - text: "MY VIEW", - height: 240, - bottomMargin: 6, - textSize: 45 - }); - - modesButtons = [buttonRadarMode, buttonMyViewMode]; - - var mode = getCurrentModeSetting(); - - var buttonsRevealed = false; - bar.sendToQml({type: "inactiveButtonsHidden"}); - - modesbar = { - restoreMyViewButton: function() { - switchModeButtons(buttonMyViewMode); - saveCurrentModeSetting(MODE_MY_VIEW); - }, - sendToQml: function(o) { bar.sendToQml(o); }, - qmlFragment: bar - }; - - buttonRadarMode.clicked.connect(function() { - //if (connections.isVisible()) return; - saveCurrentModeSetting(MODE_RADAR); - printd("Radar clicked"); - onButtonClicked(buttonRadarMode, function() { - radar.startRadarMode(); - }); - }); - buttonMyViewMode.clicked.connect(function() { - //if (connections.isVisible()) return; - saveCurrentModeSetting(MODE_MY_VIEW); - printd("My View clicked"); - onButtonClicked(buttonMyViewMode, function() { - if (currentSelectedBtn == buttonRadarMode) { - radar.endRadarMode(); - } - }); - }); - - var savedButton; - if (mode == MODE_MY_VIEW) { - savedButton = buttonMyViewMode; - } else { - savedButton = buttonRadarMode; - } - printd("[MODE] previous mode " + mode); - - savedButton.clicked(); -} - function saveCurrentModeSetting(mode) { Settings.setValue(SETTING_CURRENT_MODE_KEY, mode); } @@ -123,62 +75,29 @@ function getCurrentModeSetting(mode) { return Settings.getValue(SETTING_CURRENT_MODE_KEY, DEFAULT_MODE); } -function showAllButtons() { - for (var i=0; i